Help with simple character choice

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
yasminuscula
Newbie
Posts: 7
Joined: Tue May 24, 2022 9:15 pm
Contact:

Help with simple character choice

#1 Post by yasminuscula »

So im creating a game were I want the player to be able to choose between 3 options of characters (female, male and nonbinary).
Basically what was answered here ( viewtopic.php?t=41843 ) but I don't know if it would workout with 3 options instead of 2.

And also how do I go about coding to show the option that the player chose as a side image.

User avatar
m_from_space
Miko-Class Veteran
Posts: 949
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Help with simple character choice

#2 Post by m_from_space »

Well it's pretty much the same, just add a third line within the question and a third option inside the image:

Code: Select all

image mysprite = ConditionSwitch(
    "gender=='male'", "male_sprite.png",
    "gender=='female'", "female_sprite.png",
    "gender=='nonbinary'", "nonbinary_sprite.png")
You will figure out the rest. ;)

edit:
One option inside the ConditionSwitch() function should always be true, so it's better to write the following, assuming that if the player didn't pick male or female we just assume it's nonbinary, regardless of what is inside the variable "gender". Otherwise if the variable would contain None or another value, the function would throw an error and the game crashes.

Code: Select all

image mysprite = ConditionSwitch(
    "gender=='male'", "male_sprite.png",
    "gender=='female'", "female_sprite.png",
    "True", "nonbinary_sprite.png")

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot]