Coding Fatale
Posted on February 11, 2023
This article will show how to create a menu that will remember the player's choices.
Variables
Start by creating the variables for the menu. This will help keep track what events are going to happen in the story. For example, the character is getting ready for the day and they have a daily routine. We want the player to select choices on which actions the character can do.
default tasks_completed = 0
default teeth = False
default clothes = False
default face = False
We are going to use task_completed for a points base system that will be implemented later. Set the default value to 0.
Creating the menu
Create a menu to show the choices the player can choose.
The player can choose 3 choices, brush teeth, wash face, and get dressed.
menu daily_routine:
"Brush teeth":
jump brush_teeth
"Get dressed":
jump get_dressed
"Wash face":
jump wash_face
When a choice is selected it jumps to its label.
Remembering menu choices
Restrict the player choices to prevent choosing the same option twice. Conditional statements and the variables that were defined above will be added to the daily_routine menu. To remove a choice after it has been selected, we will use a conditional statement.
"Brush teeth" if teeth == False :
$ teeth = True
jump brush_teeth
If the character has not brushed their teeth, it is false. Once the player selects "Brush teeth" it will be made true and jump to the label. After the choice is selected, it will disappear from the menu.
Adding new choice based using a points based system
There are multiple ways to display a is a choice happens if conditions are met. The task_completed variable keeps track of the daily routine tasks that are completed.
$ tasks_completed += 1
Each time there is a choice that is selected, task_completed increments by 1.
Adding new choice
Next, we are adding a new choice that appears when a condition is met. The new "Eat breakfast" choice is when the character eats their breakfast once the daily routine is completed. Add a conditional statement.
"Eat breakfast" if tasks_completed > 2:
jump eat_breakfast
The task_completed variable is used to keep track of the points. The choice "Eat breakfast" will appear after task_completed is greater than two.
Menu with all choices
This is a menu that will remember the player choices.
menu daily_routine:
"Brush teeth" if teeth == False :
$ teeth = True
$ tasks_completed += 1
jump brush_teeth
"Get dressed" if clothes == False :
$ clothes = True
$ tasks_completed += 1
jump get_dressed
"Wash face" if face == False:
$ face = True
$ tasks_completed += 1
jump wash_face
"Eat breakfast" if tasks_completed > 2:
jump eat_breakfast
Resources
Official Ren'Py documentation:
Posted on February 11, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.