Skip to main content

Use Menu / Create Choice

Author: NingNing
Last update:2022-05-20


Menu is smth like a branch - like this: image alt

Let the player have at least 2 choices to make, you can also add some variables to let the player's choice affect the following plot or increase favorability

Advance preparation

Before we start let's have 2 characters to talk to

define a=Character("Person A")
define b=Character("Person B")

In addition, we can also put a background in the back

  • image park = "images/bg/park.jpg"

In addition to roles let's set some variables

For more information on what variables are, please refer to the following articles:
$cha_aff = 0
$chb_aff = 0
default apple = False
default banana = False
✨✨
  • Variables such as numbers can be stored using $
  • For text use define or default
  • But using default I think is better because using define can easily cause problems when saving/loding files

Create the first branch (/menu)

The code used to create branch in renpy is menu It is written like this:

menu:
"choice 1":

"choice 2":
  • Add : after Menu!
  • Remember to add : after each option/choice
  • The word displayed for each option should be enclosed in 2 quotation marks ""
  • In the sentence after : of each selection, you can write the action to be performed after an option is selected

Display text after selection

You can type dialogue directly after the : of each option like this:

menu:
"apple":
"Apple is delicious"
"banana":
"Banana is delicious"
  • The phrase "Apple is delicious" will be displayed after the player selects 🍎Apple
  • The phrase "Banana is delicious" will now be displayed after the player has selected 🍌Banana

If you want to assign a character to say "apples are delicious" or "bananas are delicious", just add the character's code name before the sentence.
example:

menu:
"apple":
a "Apple is delicious"
"banana":
b "Banana is delicious"

Increase favorability after selection

At this time, you can use defined $cha_aff = 0 and $chab_aff = 0 Example of use:

menu:
"apple":
a "Apple is delicious"
$cha_aff += 1
"banana":
b "Banana is delicious"
$chb_aff += 1

Confirm that the favorability has indeed increased

An easy way to see if your favorability has increased you can do it like this
First create a new label, the name of the label doesn't matter
example:

label stats:
"Person A's favorability is [cha_aff]"
"Person B's favorability is [chb_aff]"
  • The word inside [] = your variable, the word inside must be the same as the name you defined earlier

So your code could look like this:

menu:
"apple":
a "Apple is delicious"
$cha_aff += 1
jump stats
"banana":
b "Banana is delicious"
$chb_aff += 1
jump stats

label stats:
"Person A's favorability is [cha_aff]"
"Person B's favorability is [chb_aff]"

Jump to the plot based on your favorability

Maybe you want to jump to a special plot based on the favorability (like maybe over 10 point)
This is where you use if statements and jump
So its code can look like this

if cha_aff >= chb_aff: 
jump next1
else:
jump next2
  • The meaning of these two sentences is - when the value of cha_aff (favorability) is greater than chb_aff, skip to next1
  • If the value of cha_aff (favorability) is less than chb_aff, skip to next2

So your code can look like this:

menu:
"apple":
a "Apple is delicious"
$cha_aff += 1
"banana":
b "Banana is delicious"
$chb_aff += 1

if cha_aff >= chb_aff:
jump next1
else:
jump next2

label next1:
"Apple is awesome, person A likes your choice!"
jump start
label next2:
"Banana is awesome, person B likes your choice!"

Jump to the plot according to the event

In addition to the favorability, you can also jump to the plot based on the events that the character has experienced.
At this time, you can use the two sentences you defined - $end1 = false and $end2 = false
So your code could look like this:

menu:
"Apple":
a "Apple is delicious"
$apple = True
"Banana":
b "Banana is delicious"
$banana = True

if apple == True:
jump appleTrue
elif banana == True:
jump bananaTrue
else:
jump start
  • to use this you are creating another 2 label - appleTrue and bananaTrue

In addition to jumping directly to another Label, you can also add the sentence to be written directly after the if statement something like this:

menu:
"Apple":
a "Apple is delicious"
$apple = True
"Banana":
b "Banana is delicious"
$banana = True

if apple == True:
"Yeah aplle is so nice"
elif banana == True:
"Yeah banana is so nice"
else:
"hmmm... you should not see this sentence!"

This post is over now~ You can give me / my website a clap if this help you! My website --> https://spaceofningningen.blogspot.com/ Image Alt Thank you for your support~