Menu syntax

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
User avatar
infructescence
Newbie
Posts: 5
Joined: Fri Nov 12, 2021 2:59 pm
itch: leafletgames
Contact:

Menu syntax

#1 Post by infructescence » Tue Mar 08, 2022 7:49 am

Hello! This is maybe a silly question, but I haven't found the answer anywhere so I thought I'd ask here.

Basically, when I look up tutorials and things about creating a menu, most examples I see are formatted like this:

Code: Select all

label menuexample:

    menu:

        "Choice 1":

            jump choice1

        "Choice 2":

            jump choice2

label choice1:

    "This is what happens here."

    jump nextlabel

label choice2:

    "Something else happens here."

    jump nextlabel

label nextlabel:

    "The game continues here."
My question is, is there any reason why it shouldn't be formatted like this?:

Code: Select all

label menuexample:

    menu:

        "Choice 1":

            "This is what happens here."

            jump nextlabel

        "Choice 2":

            "Something else happens here."

            jump nextlabel

label nextlabel:

    "The game continues here."
Is it one of these things where it is personal preference or is the first way more "correct" and if so, why?

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

Re: Menu syntax

#2 Post by Ocelot » Tue Mar 08, 2022 7:57 am

You don't even need nextlabel:

Code: Select all

label menuexample:
    menu:
        "Choice 1":
            "This is what happens here."
        "Choice 2":
            "Something else happens here."
    "The game continues here."
Generally it is a matter of preference. However:
1) If you move choice actions in their own label, you can jump to it from somewhere else. It helps, if you have something which should be called from several places.
2) If your action is big, it is harder to reason about menu as a whole: imagine each choice having over 100 lines, you wouldn't be able to see all possible choices on same screen when editing.
< < insert Rick Cook quote here > >

User avatar
infructescence
Newbie
Posts: 5
Joined: Fri Nov 12, 2021 2:59 pm
itch: leafletgames
Contact:

Re: Menu syntax

#3 Post by infructescence » Tue Mar 08, 2022 7:59 am

Thank you so much! You answered exactly what I was wondering about.

Post Reply

Who is online

Users browsing this forum: Alex, Bing [Bot], Google [Bot], Ocelot