Which method for menu choices to use?

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
kostek00
Regular
Posts: 103
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Which method for menu choices to use?

#1 Post by kostek00 » Mon May 21, 2018 1:07 pm

I'm wondering which option for making menu choices I should do. Does that make any difference?
Option 1:

Code: Select all

    menu:
        "Choice 1":
            jump 1a
        "Choice 2":
            jump 1b
            
    label 1a:
    #dialogs here
    jump 1con
    
    label 2b:
    #dialogs here
    jump 1con
    
    label 1con:
Or option 2:

Code: Select all

    menu:
        "Choice 1":
            #dialogs here
            jump 1con
            
        "Choice 2":
            #dialogs here
            jump 1con
            
    label 1con

kivik
Miko-Class Veteran
Posts: 784
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Which method for menu choices to use?

#2 Post by kivik » Mon May 21, 2018 2:21 pm

Both are basically the same, so it's up to you, however if you call the labels, you can do this:

Code: Select all

    menu:
        "Choice 1":
            call label1a
        "Choice 2":
            call label 1b
    jump label1con
    
    label label1a:
        #dialogs here
        return    
    label label2b:
        #dialogs here
        return
    
    label label1con:
Note that I've changed all your labels, because labels cannot start with a number - it has to start withe a letter - so your labels won't work.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1337
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: Which method for menu choices to use?

#3 Post by xavimat » Mon May 21, 2018 5:25 pm

As kivik says, it's up to you. This is how I prefer:
If dialogs in that part are short, I prefer option 2. If they are long, I prefer option 1 for readability.
From a player point of view, there is no difference.
I also use jumps, only calls when labes are reused (called from different parts of the game) also for readability.
If there are more levels of indentation (nested menus) I prefer jumps (you guessed it, I found it more readable).
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
unknown [Sci-Fi - mystery - computer]
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Remix
Eileen-Class Veteran
Posts: 1017
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Which method for menu choices to use?

#4 Post by Remix » Tue May 22, 2018 7:53 am

Personally I tend toward a style reminiscent of old school emacs even though I now use sublime on windows ... (eek, windows... pretty odd for a username reflecting an Android OS and emulator that the great Linus Torvalds works on... hmmm)

You may have noticed that most editors can add a ruler at a set distance and most support a range of values including 72 and 78 which, for info, are the maximum line width supported by PEP-8 which Python uses for all code submissions.

So, basically, I work toward code/script writing with a maximum 79 characters per line...

For me:

All labels start at character 0 (no nested labels)
Choices/menus tend toward jump/call rather than dialogue unless said dialogue is minimal
Inline comments (mostly just before labels) help reference code flow
Naming protocol of labels also helps manage game flow and back referencing
Most screen widgets and defines use blocks rather than single line

Basically I do everything I need to try to stay under the 79 characters so prefer options that allow me to drop back to character 0 (or just 4 less) wherever possible.
Mad Scientist Todo List:
  • Finish Improved Event Handler
  • Implement DragonBones animation as a Creator Defined Container
  • Finish Catmull-Rom Spline pathing
  • Finish Bitmask collision and rebound vector system
  • Develop time based building mechanic
  • Others
  • *Find a superb artist and actually write a game*

User avatar
kostek00
Regular
Posts: 103
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Re: Which method for menu choices to use?

#5 Post by kostek00 » Tue May 22, 2018 2:33 pm

Thank you for explanation and your opinions. =]

Wasn't sure if those two methods are different.

That gives me a thought that I can make separate file (choices.rpy) for menu choices and place there all dialogs from choices and in main file just call them.

Post Reply

Who is online

Users browsing this forum: No registered users