Options changing in a menu depending on what was picked

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
quinnsea
Regular
Posts: 59
Joined: Wed Apr 26, 2017 5:04 pm
Completed: Birch Sapling
Projects: Aspen, Baleen
Organization: Koimarina Games
IRC Nick: quinnsea
Tumblr: bonnievoyage
Soundcloud: nishiikigoi
itch: koimarina
Location: Missouri
Contact:

Options changing in a menu depending on what was picked

#1 Post by quinnsea »

God, this sounded so much easier to code when I put it on Google Drive...

Alright, so the menu in this is supposed to start off with three options: Millennium Park, Navy Pier, and Sears Tower.

After picking the Sears Tower, the player learns some information that brings them back to that menu but the Sears Tower is changed to Willis Tower.

After picking the Willis Tower, the player learns some more information that brings them back to that menu but the Willis Tower is changed to John Hancock Observatory.

The way I'm trying to set this up is so the player can hear all about all the options before deciding on something.

I tried to do the code myself, but I'm kind of feeling this sense of overwhelming dread that it's horribly broken and not gonna work. So I'm getting this out of the way now before I forget to ask people about it later. Here's my attempt at how that code is supposed to work:

Code: Select all

    p "It’s pretty close to the middle of downtown at night, a perfect time for Ignite to attack."
    p "I want to be there ahead of time."
    p "Maybe if I’m on location and ready I can finally apprehend him."
    j "Does that mean I should break in my outfit too?"
    p "It wouldn’t hurt to have it on underneath just in case."
    p "I feel like we will work well together."
    p "But you don’t have to go ahead and do that right away, the concert isn’t going to start for a while."
    p "Is there any place you would like to go? I’ll accompany you."
    
label menu_2b:
    menu:
        "Millennium Park":
            
            j "Can you take me to Millennium Park anyways?"
            j "I don’t wanna miss the concert."
            p "I think if we go there this early, there’s a chance Subspectrum will still be setting up."
            p "Are you sure you want to go straight to Millennium Park?"
            
            menu:
                "Yes":
                    
                    j "I’m not gonna get a bad spot at that concert, Prism."
                    j "I’ve gotta be right up front so I can high five Magenta, Prism."
                    j "We’re goin’."
                    p "Haha! Understood! I’ll take you there!"
                    
                    jump ch2_cyan
                    
                "No":
                    
                    j "Nah, we can go somewhere else."
                    p "Alright, where would you like to go?"
                    
                    jump menu_2b
                    
                    
        "Navy Pier":

            j "It nice out enough to go to the Navy Pier?"
            p "I’m not sure! I feel like it is since I ended up overcharging today..."
            p "The Navy Pier is a favorite spot of mine. It reminds me of... another time."
            p "Would you like to go?"
            
            menu:
                "Yes":
                    
                    jump ch2_prism
                    
                "No":
                    
                    j "Hm... I dunno."
                    p "Alright, do you have something else in mind?"
                    
                    jump menu_2b
            
        "Sears Tower":
            
                $ searstower = True
                
                j "What about the Sears Tower?"
                p "Oh, I’m sorry to tell you that the Sears Tower was decimated by one of Ignite’s attacks."
                j "Fuckin’ dickhead ruining fuckin’ everything."
                p "Yes, but you can ask me about some place else."
                
                jump menu_2b
                
        "Willis Tower" if searstower:
            
            $ willistower = True
            
            j "Willis Tower still up?"
            p "Er... no. It's not."
            
        label ch2_newstalk:
                
            p "The John Hancock Observatory is still up if you want to go to a tall building."
            p "Right now, it's essentially the news building. It's where the Aspen Newspaper writes and prints their work."
            p "It's also where the talk show I went on yesterday was filmed."
            p "So we could say you've already gone, but we can go again if you'd like."
            
            menu:
                "Yes":
                    
                    jump ch2_riley
                    
                "No":

                    j "Hm... Nah, not much to see up there is there?"
                    p "Not clearly, at least."
                    p "Do you have any other ideas?"
                    
                    jump menu_2b
                    
        "John Hancock Observatory" if willistower:
            
            j "Tell me about the John Hancock building again?"
            p "Oh, sure thing."
            
            jump ch2_newstalk
I feel like my indentations are wrong, there's probably an easier way to code this, or there's something I'm just missing but I don't know exactly what. Thanks for the help!
Last edited by quinnsea on Mon Jun 19, 2017 6:06 pm, edited 1 time in total.
ImageImage

quinn / 26 / qa analyst, game design hobbyist
icon by church

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Options changing in a menu depending on what was picked

#2 Post by Alex »

Check the page about menus - https://www.renpy.org/doc/html/menus.html
This definetely make your life easier...;)

User avatar
quinnsea
Regular
Posts: 59
Joined: Wed Apr 26, 2017 5:04 pm
Completed: Birch Sapling
Projects: Aspen, Baleen
Organization: Koimarina Games
IRC Nick: quinnsea
Tumblr: bonnievoyage
Soundcloud: nishiikigoi
itch: koimarina
Location: Missouri
Contact:

Re: Options changing in a menu depending on what was picked

#3 Post by quinnsea »

Oh, right! Thanks! I edited the code so it's a bit more... coherent? Condensed?

I'm still not sure how to get rid of the old options, though.
ImageImage

quinn / 26 / qa analyst, game design hobbyist
icon by church

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Options changing in a menu depending on what was picked

#4 Post by Imperf3kt »

Do you want the player to still be able to choose sears tower, or are they locked to the willis tower route?

I can think of two ways to improve your code, but it depends what exactly you want.

E: okay, I see. Gimme twenty minutes. (At work, , job must come first)
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
quinnsea
Regular
Posts: 59
Joined: Wed Apr 26, 2017 5:04 pm
Completed: Birch Sapling
Projects: Aspen, Baleen
Organization: Koimarina Games
IRC Nick: quinnsea
Tumblr: bonnievoyage
Soundcloud: nishiikigoi
itch: koimarina
Location: Missouri
Contact:

Re: Options changing in a menu depending on what was picked

#5 Post by quinnsea »

No, after they choose Sears Tower once it should disappear. (Willis and John Hancock not shown yet.)

Then, after they pick Willis Tower that'll disappear and be replaced with John Hancock.
ImageImage

quinn / 26 / qa analyst, game design hobbyist
icon by church

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Options changing in a menu depending on what was picked

#6 Post by Imperf3kt »

Your issue is indentation and order. Try this:
Before your start label, add:

Code: Select all

default menu_2)_var == 0

Code: Select all

    p "It’s pretty close to the middle of downtown at night, a perfect time for Ignite to attack."
    p "I want to be there ahead of time."
    p "Maybe if I’m on location and ready I can finally apprehend him."
    j "Does that mean I should break in my outfit too?"
    p "It wouldn’t hurt to have it on underneath just in case."
    p "I feel like we will work well together."
    p "But you don’t have to go ahead and do that right away, the concert isn’t going to start for a while."
    p "Is there any place you would like to go? I’ll accompany you."
    
label menu_2b:
    menu:
        "Millennium Park":
            
            j "Can you take me to Millennium Park anyways?"
            j "I don’t wanna miss the concert."
            p "I think if we go there this early, there’s a chance Subspectrum will still be setting up."
            p "Are you sure you want to go straight to Millennium Park?"
            
            menu:
                "Yes":
                    
                    j "I’m not gonna get a bad spot at that concert, Prism."
                    j "I’ve gotta be right up front so I can high five Magenta, Prism."
                    j "We’re goin’."
                    p "Haha! Understood! I’ll take you there!"
                    
                    jump ch2_cyan
                    
                "No":
                    
                    j "Nah, we can go somewhere else."
                    p "Alright, where would you like to go?"
                    
                    jump menu_2b
                    
                    
        "Navy Pier":

            j "It nice out enough to go to the Navy Pier?"
            p "I’m not sure! I feel like it is since I ended up overcharging today..."
            p "The Navy Pier is a favorite spot of mine. It reminds me of... another time."
            p "Would you like to go?"
            
            menu:
                "Yes":
                    
                    jump ch2_prism
                    
                "No":
                    
                    j "Hm... I dunno."
                    p "Alright, do you have something else in mind?"
                    
                    jump menu_2b
            
        if menu_2b_var == 0:
            "Sears Tower":
            
                $ menu_2b_var += 1

                j "What about the Sears Tower?"
                p "Oh, I’m sorry to tell you that the Sears Tower was decimated by one of Ignite’s attacks."
                j "Fuckin’ dickhead ruining fuckin’ everything."
                p "Yes, but you can ask me about some place else."

                jump menu_2b
                
        elif menu_2b_var == 1:
            "Willis Tower":
            
                $ menu_2b_var += 1
            
                j "Willis Tower still up?"
                p "Er... no. It's not."

                jump menu_2b

        elif menu_2b_var == 2:
            "John Hancock Observatory":
            
                j "Tell me about the John Hancock building again?"
                p "Oh, sure thing."
            
                jump ch2_newstalk
## the above jump isn't really necessary

label ch2_newstalk:
                
    p "The John Hancock Observatory is still up if you want to go to a tall building."
    p "Right now, it's essentially the news building. It's where the Aspen Newspaper writes and prints their work."
    p "It's also where the talk show I went on yesterday was filmed."
    p "So we could say you've already gone, but we can go again if you'd like."
            
    menu:
        "Yes":
                    
            jump ch2_riley
                    
        "No":

            j "Hm... Nah, not much to see up there is there?"
            p "Not clearly, at least."
            p "Do you have any other ideas?"
                    
            jump menu_2b
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
quinnsea
Regular
Posts: 59
Joined: Wed Apr 26, 2017 5:04 pm
Completed: Birch Sapling
Projects: Aspen, Baleen
Organization: Koimarina Games
IRC Nick: quinnsea
Tumblr: bonnievoyage
Soundcloud: nishiikigoi
itch: koimarina
Location: Missouri
Contact:

Re: Options changing in a menu depending on what was picked

#7 Post by quinnsea »

Got it! Thanks a bunch!
ImageImage

quinn / 26 / qa analyst, game design hobbyist
icon by church

Post Reply

Who is online

Users browsing this forum: Google [Bot], Nozori_Games