Page 1 of 1

Trying to make my menu offer another option once all others have been chosen

Posted: Tue Jul 25, 2017 4:21 am
by LeviathanXyzzy
Hello, I'm a little new to Ren'py, and I need a little help. I'm using a menu and flags to remove the choices once they've been picked, but I can't get a final option to pop up once all of them have been picked.
For example, once library, general store, bar and diner, and walk around have been chosen, I want the option of 'Go to cabin' to pop up. Any ideas?

Code: Select all

label lookaroundmenu:
    
menu:
    
    nar "Where should you go to first?"
    
    "The Library." if library_visited_done == False:
        
        $ library_visited_done = True
        
        jump thelibrary
    
    "The General Store." if generalstore_visited_done == False:
        
        $ generalstore_visited_done = True
        
        jump generalstore
        
    "The Bar and Diner." if baranddiner_visited_done == False:
        
        $ baranddiner_visited_done = True
        
        jump baranddiner
    
    "Walk around." if walkaround_done == False:
        
        $ walkaround_done = True
        
        jump walkaround

label thelibrary:
    
    nar "You walked to the rather small library, interested in if it had anything instore for you."

jump lookaroundmenu

label generalstore:
    
    nar "You walked up the short steps to the general store, taking note of the fresh red paint on the porch. Maybe they were renovating a bit?"

jump lookaroundmenu
    
label baranddiner:
    
    nar "Your stomach had been growling not too long ago. Maybe something to eat would satisfy you?"
    
jump lookaroundmenu
    
label walkaround:
    
    nar "You choose to walk around, interested in the sights."

    nar "You found there to be a town hall, which might actually have some answers about this places history."
    
jump lookaroundmenu
    
label chooseagain:
    
    nar "You've already done that. Try again."
    
    jump lookaroundmenu
    
return




Re: Trying to make my menu offer another option once all others have been chosen

Posted: Tue Jul 25, 2017 5:55 am
by warmsundae
I hope there's a simpler method, but here's what I would do:

Code: Select all

label lookaroundmenu:

if library_visited_done:
    if generalstore_visited_done:
        if baranddiner_visited_done:
            if walkaround_done:
                $ gotocabin = True
            else:
                pass
        else:
            pass
    else:
        pass
else:
    pass
    
menu:
    
    nar "Where should you go to first?"
    
    "The Library." if library_visited_done == False:
        
        $ library_visited_done = True
        
        jump thelibrary
    
    "The General Store." if generalstore_visited_done == False:
        
        $ generalstore_visited_done = True
        
        jump generalstore
        
    "The Bar and Diner." if baranddiner_visited_done == False:
        
        $ baranddiner_visited_done = True
        
        jump baranddiner
 
    "Walk around." if walkaround_done == False:
        
        $ walkaround_done = True
        
        jump walkaround
        
    "Go to cabin." if gotocabin == True:
    
        jump gotocabin
also, you can label menus like

Code: Select all

menu lookaroundmenu:
but I can't remember if you can put "if/else" code after a menu label.

Re: Trying to make my menu offer another option once all others have been chosen

Posted: Tue Jul 25, 2017 6:34 am
by Remix
Inline in the menu should be fine

Code: Select all

    "Go to cabin." if walkaround_done and baranddiner_done and etc etc:
        jump gotocabin

Re: Trying to make my menu offer another option once all others have been chosen

Posted: Tue Jul 25, 2017 6:41 am
by wyverngem
Much easier to do Remix's line and I would go with that. @warmsundae You can use and and or on if conditions so you don't have to write the code like you did. This suffices.

Code: Select all

if library_visited_done == True and generalstore_visited_done == True and baranddiner_visited_done == True and walkaround_done == True:
    jump my_label
There's really no need to write an else statement if it's going to be blank. Only if it does something.

Re: Trying to make my menu offer another option once all others have been chosen

Posted: Wed Jul 26, 2017 12:23 am
by shin.e.d
There's an undocumented feature in menus that'll remove choices automatically.
(first found it mentioned by Ocelot over in this thread.)
So you can potentially write something like this:

Code: Select all

## Use default to declare some variables to be used in the script.
default visited=[]
default jogged=False

label menu_loop:
    menu:
        
        ## this variable holds a list of the choices chosen and hides them.
        set visited
        
        "The Library.":
            call thelibrary2
            jump menu_loop
        
        "The General Store.":
            call generalstore2
            jump menu_loop
        
        "The Bar and Diner.":
            call baranddiner2
            jump menu_loop
        
        "Walk around." if not jogged: ## if statements still work too.
            call walkaround2
            jump menu_loop
        
        "or jog around!" if not "Walk around." in visited: ## also this.
            $jogged=True
            "You found the town's town hall and got some good exercise too."
            jump menu_loop
    
    ## The game continues down here if there's no jump statement,
    ## or when the above menu is out of choices.
    menu:
        "Go to cabin.":
            "You head back to the cabin."
            
            ## this return ends the game if the call stack is empty.
            return

## Note that if you use the same 'set name_here' again with another menu it
## would have the problem of hiding choices that were picked before.
## So either use a new variable everytime or reset it with this: $visited=[]

label thelibrary2:
    "You walked to the rather small library, interested in if it had anything instore for you."
    return
label generalstore2:
    "You walked up the short steps to the general store, taking note of the fresh
        red paint on the porch. Maybe they were renovating a bit?"
    return
label baranddiner2:
    "Your stomach had been growling not too long ago. Maybe something to eat would satisfy you?"
    return
label walkaround2:
    "You choose to walk around, interested in the sights."
    "You found there to be a town hall, which might actually have some answers about this places history."
    return