(SOLVED)How to jump to a new label when all menu options have been selected?

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
YumaDazai
Regular
Posts: 34
Joined: Wed Jul 04, 2018 4:10 pm
Projects: PD9
Contact:

(SOLVED)How to jump to a new label when all menu options have been selected?

#1 Post by YumaDazai »

So I'm coding a visual novel, and at one part you have 3 options that disappear after you select them. How can I jump to the next part of the story after all of the options have been selected?

Code: Select all

label 3d:
  
    $ white = 1
    $ red = 1
    $ yellow = 1

Code: Select all

menu flowers:
    "White" if white:
        $ white = 0
         jump white
    "Red"  if red:
        $ red = 0
         jump red
    "Yellow" if yellow:
        $ yellow = 0
         jump yellow
         
         #what do I do after this?

Or would this work better?

Code: Select all

 #before start label
default white = False
default red = False
default yellow = False

Code: Select all

menu flowers:
    "White" if not white:
         jump white
    "Red"  if not red:
         jump red
    "Yellow" if not yellow:
         jump yellow

Code: Select all

#at the end of each label jump
if white and red and yellow:
   jump cs
else:
    jump menu flowers
Last edited by YumaDazai on Mon Aug 13, 2018 6:58 pm, edited 3 times in total.
Programmer that will work paid and or for free! Message me on discord for more info at: Yuma#8158

User avatar
dGameBoy101b
Regular
Posts: 31
Joined: Sun Aug 12, 2018 8:32 am
itch: dgameboy101b
Contact:

Re: How to jump to a new label when all menu options have been selected?

#2 Post by dGameBoy101b »

All you need to do is add an if test after the menu to test for all selected choices. Also using the call statement allows you to easily get back to the menu once the player has finished a particular choice's route.

Code: Select all

label flowers:
     menu flowers:
        "White" if white:
            $ white = 0
             call white
         "Red"  if red:
            $ red = 0
             call red
         "Yellow" if yellow:
             $ yellow = 0
              call yellow  
          if white == 0 and red == 0 and yellow == 0:
              jump continue
           else:
               jump flowers
label continue:              
Last edited by dGameBoy101b on Thu Sep 13, 2018 8:09 am, edited 1 time in total.

User avatar
YumaDazai
Regular
Posts: 34
Joined: Wed Jul 04, 2018 4:10 pm
Projects: PD9
Contact:

Re: How to jump to a new label when all menu options have been selected?

#3 Post by YumaDazai »

Thank you!
Programmer that will work paid and or for free! Message me on discord for more info at: Yuma#8158

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: How to jump to a new label when all menu options have been selected?

#4 Post by philat »

You can also use this undocumented but useful behavior: viewtopic.php?f=8&t=42976#p447121

Code: Select all

label 3d:
    $ flowers_set = []
    menu flowers:
        set flowers_set
        "White":
            call white
        "Red":
            call red
        "Yellow":
            call yellow  
    if len(flowers_set) < 3:
        jump flowers
    # implicitly, if the length of flowers_set is 3 or greater, it will fall through to the label cs
    # if the script is organized differently, you can also add an explicit else jump cs

label cs:
    "stuff"

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to jump to a new label when all menu options have been selected?

#5 Post by trooper6 »

I would do this like so:

Code: Select all

default flowers_set = []

label start:
    "Your game starts."
    
    menu flowers:
        set flowers_set
        "Choose a flower."
        "White":
             jump white
        "Red":
             jump red
        "Yellow":
             jump yellow
             
    "Your game continues here."
    "Your game is over."
    return
    
label white:
    "You look at the white flowers."
    jump flowers
    
label red:
    "You look at the red flowers."
    jump flowers
    
label yellow:
    "You look at the yellow flowers."
    jump flowers 
Very importantly, I wouldn't call the white/red/yellow...I'd jump, so that you can jump to the menu rather than return (which would put you at the end of the menu, not repeat it).
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
dGameBoy101b
Regular
Posts: 31
Joined: Sun Aug 12, 2018 8:32 am
itch: dgameboy101b
Contact:

Re: How to jump to a new label when all menu options have been selected?

#6 Post by dGameBoy101b »

I wouldn't call the white/red/yellow...I'd jump, so that you can jump to the menu rather than return
By calling the flower text you can easily access the same text again from somewhere else without worrying about where it is beinging called from as it will just return to where it was called like so.

Code: Select all

default flowers = []
menu:
    set flowers
    "Oh, some flowers!"
    "white":
    	call white_flowers
    "red":
    	call red_flowers
    "yellow":
    	call yellow_flowers
jump continue
label white_flowers:
    "Some lovely white flowers."
    return
label red_flowers:
    "some lovely red flowers."
    return
label yellow_flowers:
    "Some lovely yellow flowers."
    return
label continue:
    "I continue walking."
    menu:
        "How lucky am I! Some more flowers!"
        "red":
            call red_flowers
        "white":
            call white_flowers
    jump continue1
Also that set behaviour is so cool! I've been doing that manually before now.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: (SOLVED)How to jump to a new label when all menu options have been selected?

#7 Post by trooper6 »

That the call returns where you came from is exactly why you shouldn't use it in this instance.

You had to create a secondary menu that repeats the first menu with one of the options taken out. My version just uses one menu. It is much more efficient. The way you set up your code, the set function is never used because you never return back to the top of the original menu.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
dGameBoy101b
Regular
Posts: 31
Joined: Sun Aug 12, 2018 8:32 am
itch: dgameboy101b
Contact:

Re: (SOLVED)How to jump to a new label when all menu options have been selected?

#8 Post by dGameBoy101b »

trooper6 wrote: Mon Aug 13, 2018 10:58 pm That the call returns where you came from is exactly why you shouldn't use it in this instance.

You had to create a secondary menu that repeats the first menu with one of the options taken out. My version just uses one menu. It is much more efficient. The way you set up your code, the set function is never used because you never return back to the top of the original menu.
My previous code was not demonstrating how to repeat a menu only how the sub labels of the first menu can be recalled from another part of the code if, for instance, the main character encounters a similar bed of flowers.

Post Reply

Who is online

Users browsing this forum: No registered users