[SOLVED] Choice Menu

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
Braydxne
Regular
Posts: 50
Joined: Tue Aug 08, 2017 4:03 am
Projects: DR: Chains of Trust
Contact:

[SOLVED] Choice Menu

#1 Post by Braydxne »

Sorry for the vague title, but I'm not sure what to call this. What I want is for the player to have to examine both of the options, and then the door choice will be available.

Code: Select all

label class1:
    $ checked_desk = False
    $ checked_window = False
    
    scene classroominteract
    
    menu classexplore:
        "What should I do?"
    
        "Look at the window.":
            $ checked_window = True
        
            "Why the hell is it boarded up?"
        
        
        "Look at the desk.":
            $ checked_desk = True
        
            "I can't believe I fell asleep here..."
        
            
        "Head to the door." if checked_desk and checked_window:
            
            "I guess I should explore this place a bit more..."
That's the code I'm starting off with. However I need to know how to repeat the choice instead of automatically heading to the door. I'm sorry if this post doesn't make a lot of sense but I'm not sure how I can explain this well. I thought about having it jump to another label but then the variables don't seem to carry over.
Last edited by Braydxne on Wed Sep 20, 2017 8:27 pm, edited 1 time in total.

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Choice Menu

#2 Post by Kia »

you can put a label before your choice and jump back to it whenever you want
as for variables problem, you can use persistent variables: https://www.renpy.org/doc/html/persistent.html

User avatar
Braydxne
Regular
Posts: 50
Joined: Tue Aug 08, 2017 4:03 am
Projects: DR: Chains of Trust
Contact:

Re: Choice Menu

#3 Post by Braydxne »

Kia wrote: Wed Sep 13, 2017 12:19 am you can put a label before your choice and jump back to it whenever you want
as for variables problem, you can use persistent variables: https://www.renpy.org/doc/html/persistent.html
This worked like a charm. I can't believe the answer was so simple. Thank you very much!

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

Re: Choice Menu

#4 Post by Imperf3kt »

That is actually not the answer.
Persistent will persist (as the name implies) between new games.
What you want to do, is take all your defined variables and move them to before any label, and switch the $ for default.

Code: Select all

default checked_desk = False
default checked_window = False

label start:
# the start of your game

label class1:
    scene classroominteract

label examine:
    menu :
        "What should I do?"
    
        "Look at the window.":
            $ checked_window = True
        
            "Why the hell is it boarded up?"
        
        "Look at the desk.":
            $ checked_desk = True
        
            "I can't believe I fell asleep here..."
            
        if checked_desk and checked_window:
            "Head to the door.":
                "I guess I should explore this place a bit more..."
                jump wherever
    jump examine
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

Post Reply

Who is online

Users browsing this forum: Exiscoming