Add or remove options in a menu depending certain criterias

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
richycapy
Regular
Posts: 56
Joined: Mon May 27, 2019 8:53 pm
Organization: EN Productions
Location: Mexico
Contact:

Add or remove options in a menu depending certain criterias

#1 Post by richycapy »

Hi

Im trying to set a Menu depending on certain things during the game... example, this is the original code:

Code: Select all

$ picturetaken = False

label label_1
	"{i}She is taking walking by, what do you want to do?{/i}"

menu:
    "Leave before she see you":
        jump label_2
    "Take a picture":
        jump label_3


label label_3
        $ picturetaken = True
        play sound "sounds/fx/takepicture.mp3"
        "{i}I hope she didn't notice me{/i}"
        "{i}I better leave quickly...{/i}"
        jump label_1
        
label label_2
        "{i}I better leave...{/i}"
        jump next_scene
Very simple, just an option to take or not a picture

So, after you take the picture, I want to remove the "Take a picture" option... so, if I do this:

Code: Select all

menu:
    "Leave before she see you":
        jump label_2

    if not picturetaken:
        "Take a picture":
         jump label_3
         

Code: Select all

File "game/historias.rpy", line 1438: expected menuitem
     if not picturetaken:
    ^
And I would like, in a future, to be able to add more options, like if the player has certain amount of friendship, add the option: "Say hi" or other things

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

Re: Add or remove options in a menu depending certain criterias

#2 Post by Imperf3kt »

You only need to reverse your statement.

Code: Select all

 
    menu:
    "Leave before she see you":
        jump label_2

    "Take a picture" if not picturetaken:
         jump label_3
         
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
richycapy
Regular
Posts: 56
Joined: Mon May 27, 2019 8:53 pm
Organization: EN Productions
Location: Mexico
Contact:

Re: Add or remove options in a menu depending certain criterias

#3 Post by richycapy »

Imperf3kt wrote: Sun Nov 03, 2019 10:25 pm You only need to reverse your statement.

Code: Select all

 
    menu:
    "Leave before she see you":
        jump label_2

    "Take a picture" if not picturetaken:
         jump label_3
         
Awesome! Thanks a lot dude!! :D

Post Reply

Who is online

Users browsing this forum: No registered users