Menu items that show only under certain conditions? [SOLVED]

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
Myria
Newbie
Posts: 8
Joined: Fri Aug 14, 2015 5:29 pm
Contact:

Menu items that show only under certain conditions? [SOLVED]

#1 Post by Myria » Fri Aug 14, 2015 6:15 pm

Hey. I'm working on a game that's entirely menu based, and I am somewhat new to the engine. Some levels will have certain options that I want to be hidden in other levels. Can I do this using the same menu code, or do I have to "brute force" it and make a different menu for each? Here is the (relevant) code I have so far:

Code: Select all

label LPMenu:
    "What would you like to do?"
    menu:
        "Repeat Goal Sequence (1 of %(lpmenu_choices)i)":
            jump LPPlayGoalSequence
        
        "Edit piano function (2 of %(lpmenu_choices)i)":
            jump LPPiano
        
        if flen > 0:
            "Edit flute function (3 of  of %(lpmenu_choices)i)":
                jump LPFlute
                    
        if glen > 0:
            "Edit guitar function (%(functions + 1)i of %(lpmenu_choices)i)":
                jump LPGuitar
        
        "Test my answer (%(lpmenu_choices - 1)i of %(lpmenu_choices)i)":
            jump LPAnswer
        
        "Exit Level (%(lpmenu_choices)i of %(lpmenu_choices)i)":
            if level == -1: #just built with level-editor
                jump leditor #return them to the level editor
            
            elif level == 0: #loaded from code
                jump leditM
            
            else: #built-in level
                jump start
When I try to run it, I get this error:

Code: Select all

File "game/level_player.rpy", line 36: expected menuitem
    if flen > 0:
    ^
So it doesn't like the conditionals there, but I'm not sure how else one would optionally hide a menu choice other than just building every possible permutation of the menu, which sounds... tedious.
Last edited by Myria on Fri Aug 14, 2015 6:49 pm, edited 1 time in total.

User avatar
chocojax
Miko-Class Veteran
Posts: 702
Joined: Sun Oct 25, 2009 11:27 am
Completed: http://art.jphi.me/projects
Projects: Umbra, Familiarity, Maleficent Justice
Organization: spaceNote
Tumblr: chocojax
Github: jenniferphi
Location: California
Contact:

Re: Menu items that show only under certain conditions?

#2 Post by chocojax » Fri Aug 14, 2015 6:39 pm

http://www.renpy.org/doc/html/menus.html (bottom of page)

It should be like this:

Code: Select all

    menu:
        "Edit flute function (3 of  of %(lpmenu_choices)i)" if flen>0:
            ...

Myria
Newbie
Posts: 8
Joined: Fri Aug 14, 2015 5:29 pm
Contact:

Re: Menu items that show only under certain conditions?

#3 Post by Myria » Fri Aug 14, 2015 6:48 pm

Ahh, thank you so much! :3

Post Reply

Who is online

Users browsing this forum: Google [Bot]