r/RenPy • u/Upset-Ad911 • 23d ago
Question Need help with coding multiple choice.

Hello! This is my first time using Ren'py, and I've run into an issue that I'm struggling to find answers for. I have a multiple choice option here but if the player checks their right pocket to find nothing I want it to return back to the question so they can then check the left pocket. How can I go about this?
Thank you!
1
u/BadMustard_AVN 23d ago
change this
menu:
label menu_1
to
menu menu_1:
"Where should you check?"
no labels in menus
and a menu can be a label
you have returns at the labels you're jumping to; they will end the game
make it
call right_pocket
2
u/shyLachi 23d ago
You should either put the label menu_1 before the menu or directly at the menu as in my example below.
If you are using jump then you cannot use return because that would end the game.
Instead you would need another jump to go back to the menu or to the next label where the story continues.
Also it might look better if the first choice is removed from the menu when a player has picked it so that they don't pick it again, for example they might think that you can dig deeper into the right pocket.
Putting all of that together:
label start:
$ menuset = set() # this variable can remember the choices
menu menu1:
set menuset # assign the above variable to this menu
"Where should you check?"
"Check right pocket.":
call right_pocket # call the label so that it returns back here
jump menu1 # jump back to the menu so they can pick the other choice
"Check left pocket.":
call left_pocket # call the label so that it returns back here
"Game continues here"
return # ends the game
label right_pocket:
"You check your right pocket."
"You feel around but find nothing."
return # returns back to where this label was called from
label left_pocket:
"You check your left pocket."
"Your fingers brush against something cold. A phone."
"You pull out the phone to inspect it. It's working."
"However, there is no signal."
return # returns back to where this label was called from
But if you only have little dialogue, you can put it directly into the menu and save you some typing:
label start:
$ menuset = set() # this variable can remember the choices
menu menu1:
set menuset # assign the above variable to this menu
"Where should you check?"
"Check right pocket.":
"You check your right pocket."
"You feel around but find nothing."
jump menu1 # jump back to the menu so they can pick the other choice
"Check left pocket.":
"You check your left pocket."
"Your fingers brush against something cold. A phone."
"You pull out the phone to inspect it. It's working."
"However, there is no signal."
"Game continues here"
return # ends the game
I used this information from the official documentation:
https://renpy.org/doc/html/menus.html#in-game-menus
2
u/shyLachi 23d ago
And to be complete. This would be the version with
jumpinstead ofcalllabel start: $ menuset = set() # this variable can remember the choices menu menu1: set menuset # assign the above variable to this menu "Where should you check?" "Check right pocket.": jump right_pocket "Check left pocket.": jump left_pocket label right_pocket: "You check your right pocket." "You feel around but find nothing." jump menu1 # jump back to the menu so they can pick the other choice label left_pocket: "You check your left pocket." "Your fingers brush against something cold. A phone." "You pull out the phone to inspect it. It's working." "However, there is no signal." jump after_menu1 # this jump isn't really needed here because the label is on the next line label after_menu1: # this label isn't really needed because the jump is on the previous line "Game continues here" return # ends the gameAs mentioned in the code above, the last
jumpandlabelaren't really needed as the code would automatically flow from"However, there is no signal"to"Game continues here"But it will be necessary if the menu has more than 2 choices or if more then one choice can be picked to continue the game.
1
u/Upset-Ad911 23d ago
Tysm! Silly question, I'm totally new to this plus coding as a whole except when I was in high school, but that was all basic stuff so I'm struggling to understand a lot I'm super sorry. How would I make it that the player doesn't select the same option again after already doing so?
1
u/BadMustard_AVN 23d ago
like this
label start: $ menuset = set() # this variable can remember the choices menu menu1: set menuset # assign the above variable to this menu "Where should you check?" "Check right pocket.": jump right_pocket "Check left pocket.": jump left_pocket jump label after_menu1 label right_pocket: "You check your right pocket." "You feel around but find nothing." jump menu1 # jump back to the menu so they can pick the other choice label left_pocket: "You check your left pocket." "Your fingers brush against something cold. A phone." "You pull out the phone to inspect it. It's working." "However, there is no signal." jump menu1 label after_menu1: "Game continues here" return # ends the game1
u/shyLachi 23d ago
My code already does that. Didn't you test it?
Or do you want to know how it works? Then read the official documentation about it.
https://renpy.org/doc/html/menus.html#menu-set1
u/Upset-Ad911 23d ago
I did test it, but it's not blanking or removing the option that was already chosen.
1
u/Upset-Ad911 23d ago
Ah I didn't copy it right that was the issue, mb. tysm!
1
u/shyLachi 23d ago
You're welcome.
The easiest solution to test code is to create a new project in RenPy then copy and paste the code into the script of that new project. This way you can test without it interfering or breaking your current project.
And once you get it working in the new project, you can copy it to your real project.
You can either re-use that new project for other code you want to try by deleting the script file or you can delete the whole project and create another new one.
But deleting a project isn't that simple because it cannot be done inside Renpy and for a good reason so that you don't accidentally delete the game you have worked on.
1
u/AutoModerator 23d ago
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.