Menu Item By If statement.

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
Suru
Regular
Posts: 111
Joined: Wed Aug 31, 2016 10:27 pm
Contact:

Menu Item By If statement.

#1 Post by Suru » Thu Sep 01, 2016 2:58 pm

So I would like to make one of my menu items only available if a certain condition is met. I've tried using the if statement in the place where the menu option would normally go but that doesn't work. Does anyone know the code to make a menu choice specific to certain variables?

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: Menu Item By If statement.

#2 Post by trooper6 » Thu Sep 01, 2016 3:06 pm

This is explained in the documentation with examples. See the second example on this page: https://www.renpy.org/doc/html/menus.html
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
NocturneLight
Regular
Posts: 162
Joined: Thu Jun 30, 2016 1:20 pm
Projects: Unsound Minds: The Clarevine Epoch
Organization: Reminiscent 64
Tumblr: Reminiscent64
itch: Reminiscent64
Location: Texas
Contact:

Re: Menu Item By If statement.

#3 Post by NocturneLight » Thu Sep 01, 2016 3:10 pm

Using an if statement should of worked for you. Did you make sure to indent in all the right places?

If you did it properly, it should look something like this:

Code: Select all

if test == 1:
    menu:
        "Hi.":
            jump SecondStory_FinalMoments
        "Hola.":
            jump SecondStory_FinalMoments
The Old Guard is at His Limit. The time is near to usher in the New Guard.

The Great Horror is soon to be free.

Clarevine is the key.


"Unsound Minds: The Clarevine Epoch" is a yuri visual novel that shatters english visual novel norms and aims to blend Christianity and the Cthulhu Mythos to tell a deep and dark story that you'll enjoy. You can follow the Kickstarter here.

Stay sound and persist through the chaos,
NocturneLight

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: Menu Item By If statement.

#4 Post by trooper6 » Thu Sep 01, 2016 3:19 pm

NocturneLight, Suru doesn't want to if the entire menu (which is the code you provided), but only one choice. That is documented in the link I provided.
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
Suru
Regular
Posts: 111
Joined: Wed Aug 31, 2016 10:27 pm
Contact:

Re: Menu Item By If statement.

#5 Post by Suru » Thu Sep 01, 2016 3:23 pm

Thank you! I have it now. I was placing the if statement in the next indent below as opposed to next to the statement. Sorry for such a simple question.

Post Reply

Who is online

Users browsing this forum: Google [Bot]