Hide a choice?

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
ZaqazDeath
Regular
Posts: 46
Joined: Tue Nov 08, 2011 3:55 pm
Contact:

Hide a choice?

#1 Post by ZaqazDeath »

Umm... Is it possible to hide a dp_period choice? Like cooking. If I wanna cook then I need a kitchen. And when I get a kitchen it is unlocked. Can somebody help? Thanks.

User avatar
Gear
Miko-Class Veteran
Posts: 764
Joined: Tue Apr 05, 2011 10:15 pm
Projects: Tempestus Sum
Organization: Xenokos Interactive
IRC Nick: Gear
Skype: Skye.Gear
Location: Grand Prairie, TX
Contact:

Re: Hide a choice?

#2 Post by Gear »

Set a flag. When the kitchen is unlocked:

Code: Select all

$ kitchen_flag = True
Then, where the player is:

Code: Select all

if kitchen_flag == True:
    "Cook":
        jump food_catastrophe
"Other options":
    jump elsewhere_label
Just pay attention to the alignment. If you get it wrong, you'll end up with a mess. Like I do when I cook.
The best reason to get up in the morning is to outdo yourself: to do it better than you've ever done it before. But if you haven't done it better by nightfall... look at your globe and pick a spot: it's always morning somewhere.

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Hide a choice?

#3 Post by DragoonHP »

Code: Select all

menu:
    "Cook. if kitchen_flag == True"
        jump food_catastrophe
    "Other options."
        jump elsewhere_label
This is the correct code because menu supports this type of if...else syntax.

ZaqazDeath
Regular
Posts: 46
Joined: Tue Nov 08, 2011 3:55 pm
Contact:

Re: Hide a choice?

#4 Post by ZaqazDeath »

Thanks.

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Hide a choice?

#5 Post by DragoonHP »

Oopsie... that code is wrong...

Code: Select all

menu:
    "Cook" if kitchen_flag == True:
        jump food_catastrophe
    "Other options.":
        jump elsewhere_label
This is the right onw.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Hide a choice?

#6 Post by PyTom »

In python, there's usually no need to test for explicit truth. Writing:

Code: Select all

menu:
    "Cook" if kitchen_flag:
        jump food_catastrophe
    "Other options.":
        jump elsewhere_label
works similarly, and is more idiomatic.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

ZaqazDeath
Regular
Posts: 46
Joined: Tue Nov 08, 2011 3:55 pm
Contact:

Re: Hide a choice?

#7 Post by ZaqazDeath »

Yup. Thanks.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], AWizardWithWords