Disable/Enable choices based on previous choices

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
Destiny-Smasher
Regular
Posts: 29
Joined: Wed Aug 09, 2017 7:10 pm
Projects: DownRight Fierce, Life is Strange: All Wounds
Tumblr: destiny-smasher.tumblr.com
itch: destiny-smasher
Contact:

Disable/Enable choices based on previous choices

#1 Post by Destiny-Smasher » Wed Mar 25, 2020 11:58 am

I've been trying to find info on how to do this but am getting a bit confused.

I'm writing a VN where the protag has various stats that change based on choices the reader makes, and I want to be able to disable or enable choices based on those kinds of factors. Even if it's not possible to do with variables tied to numerical values, at least being able to do so using flags would be really useful.

As an example, I have the main character arrive at a new place, and I want to give the reader multiple chances to choose to spent their free time unpacking their things, so that a later scene in the story can play out two different ways based on whether the reader took one of those chances to unpack their belongings.

So I have
$ Unpack = False
as the default, and when the reader chooses the option, I set the flag to 'True.'

But when I get to a second opportunity, I don't know how to disable that choice for those who already picked it previously.

menu:
"Free time. What do?"
"~unpack~":

If I wanted to ENABLE a choice, ex. if I want something to happen ONLY if they have activated a flag, it looks like I could maybe do this?

menu:
"Free time. What do?"
"~invite someone over~" if Unpack:

But I don't know how to do it if the flag is not active. Would I need to make a separate flag that triggers when anything else is picked?

Basically, I want to have options not even show up as a choice if a specific flag has already been activated, although being able to do so with numerical values (ie having a choice not even show up if a certain stat isn't high enough) would also open up a lot of possibilities.

Any advice on this is appreciated! And I hope ya'll are staying safe during these crazy times.

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Disable/Enable choices based on previous choices

#2 Post by philat » Wed Mar 25, 2020 1:49 pm

You can check whether something is false the same way you check if it's true.

Code: Select all

menu:
    "Unpack" if not unpack:
        $ unpack = True
    "Invite someone over" if unpack:
        "blah blah"
    "fallback":
        pass

Dimorphodon
Newbie
Posts: 12
Joined: Sat Mar 21, 2020 9:36 pm
Contact:

Re: Disable/Enable choices based on previous choices

#3 Post by Dimorphodon » Wed Mar 25, 2020 10:14 pm

The way I do it is:

Outside of a menu:

Code: Select all

if unpack == True:
     n "blah blah"
And for a menu:

Code: Select all

menu:
        "blah":
           jump scene1
        "blah2." if unpack == True: #Tests if unpack is true
            jump scene2
in the menu's case, option "blah" will always show; "blah2" will only show if unpack is true.

User avatar
Destiny-Smasher
Regular
Posts: 29
Joined: Wed Aug 09, 2017 7:10 pm
Projects: DownRight Fierce, Life is Strange: All Wounds
Tumblr: destiny-smasher.tumblr.com
itch: destiny-smasher
Contact:

Re: Disable/Enable choices based on previous choices

#4 Post by Destiny-Smasher » Thu Mar 26, 2020 6:36 am

Thanks for the help!

Post Reply

Who is online

Users browsing this forum: Ocelot