Menus with conditional options
Sometimes options in a menu might only show up when they are relevant,
such as when some pre-condition has been met. This can be done
by adding an if expression
between the name of
the option and the colon.
The snippet for searching the study could be changed to remove the search option for each scenery item once it has been searched:
default keyFound = False default pageFound = False label study: $ renpy.dynamic('done') "You respectfully enter your grandfather's study. The room still smells the same as it always did." $ done = False while not done: menu: "{alt}Menu. {/alt}Where do you want to look?" "Search desk" if not pageFound: "You carefully search the desk and under the blotter you find a curious page of parchment covered in symbols." $ pageFound = True "Check under rug" if not keyFound: "You lift to corner of the old rug and find a small brass key." $ keyFound = True "Leave": $ done = True "You leave the study and close the door behind you." return
What if there are no valid options?
If there are no options for a menu because all of the options have
conditions that are False
then the menu isn't displayed
at all. Execution proceeds with the next line after the menu block.