my program is working but my format is wrong

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
computerwhiz10101010
Newbie
Posts: 5
Joined: Sun Jan 07, 2024 3:54 am
Contact:

my program is working but my format is wrong

#1 Post by computerwhiz10101010 »

thanks to your guys help ive made a good age verification prompt. i then made a function to cycle images and text, but i think my format is wrong. whats the right way to do this?

Code: Select all

init python:
    def show_text_with_image(image, texts):
        renpy.show(image)
        for text in texts:
            renpy.say(None, text)
            renpy.pause()
        renpy.hide(image)

# Define a list of story elements, each with an image and corresponding texts
init:
    $ story_elements = [
        {"image": "1.png", "texts": ["Text 1 for Image 1", "Text 2 for Image 1", "Text 3 for Image 1"]},
        {"image": "2.png", "texts": ["Text 1 for Image 2", "Text 2 for Image 2"]}
    ]

# The script of the game goes in this file.
default age_prompt = False

# The game starts here.
label start:
    "Welcome to My Awesome Game!"
    call age_verification_prompt
    call display_story
    return

label age_verification_prompt:
    menu:
        "All characters in this game are 18 or older. Are you 18 years old or older?"
        "Yes":
            $ age_prompt = True
        "No":
            $ age_prompt = False

    if age_prompt:
        return
    else:
        "Sorry, you must be 18 or older to play this game."
        "Goodbye!"
        $ renpy.quit()
        return

label display_story:
    python:
        for element in story_elements:
            show_text_with_image(element["image"], element["texts"])
    return

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: my program is working but my format is wrong

#2 Post by m_from_space »

computerwhiz10101010 wrote: Sun Jan 07, 2024 6:01 pm thanks to your guys help ive made a good age verification prompt. i then made a function to cycle images and text, but i think my format is wrong. whats the right way to do this?
I don't know what your "story-elements" is for, but I guess it's just some scripted "in-between" sequences? Make sure to understand that loading from within those story lines won't work, since you're calling a python block. But if you're not going to repeat this story sequence, why create a variable to begin with? It's a bad idea! Why don't you just create story and narration in a normal Renpy fashion?

Nevertheless, suggestions:

Code: Select all

...

# Use a define (if it will never change) or default (if it can change) here, don't create your game related variables inside python
define story_elements = [
    {"image": "1.png", "texts": ["Text 1 for Image 1", "Text 2 for Image 1", "Text 3 for Image 1"]},
    {"image": "2.png", "texts": ["Text 1 for Image 2", "Text 2 for Image 2"]}
]

...

# you don't need a variable here, why save the choice?
label age_verification_prompt:
    menu:
        "All characters in this game are 18 or older. Are you 18 years old or older?"
        "Yes":
            return
        "No":
            "Sorry, you must be 18 or older to play this game."
            "Goodbye!"
            $ renpy.quit()
    return

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2406
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: my program is working but my format is wrong

#3 Post by Ocelot »

What exactly is wrong? It is working for me:
https://drive.google.com/file/d/1KHZy7O ... p=drivesdk
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Lucyper