selecting character gender

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
User avatar
Bum_McFluff
Regular
Posts: 45
Joined: Sat Aug 18, 2018 8:15 pm
Contact:

selecting character gender

#1 Post by Bum_McFluff »

I want the player to be able to choose the character's gender. (later I will want to add other things they can choose other variables such as height, weight, race, religion etc but for now I'll stick to one thing)
At this stage, I am just thinking it is all from your POV, so no need to also select an image. I just want that at the start it is either set to Male or Female. Thereafter each interaction, the NPCs will refer to you as Mr or Miss, Sir or Madam, My Lord or My Lady, etc.
There may be some options that are not available to a particular gender. (Access to a person or location for example)
So I was thinking, a screen at the beginning with a menu: Select your gender: MALE or FEMALE
Either selection would set something like $ You_Male = True. (I am still basically a novice coder, so if there is a better way to set this, please let me know).
After that there would be some code which states something like: "if Male then only use male title" the titles would be set elsewhere. Maybe a list of titles to choose form as your character gains rank through experience?

Firstly, does this sound achievable in Ren'Py?
Am I on the right track to do this with $ You_Male = True, for example?
I hope I have explained what I am after properly I know what I want in my head, but maybe I'm not using the correct terms.
What, spy on our spy as he searches for their spy? Why not, sounds rather like fun.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: selecting character gender

#2 Post by namastaii »

It might be better to have one variable set either to 0 or 1 (or 1 or 2) or literal strings "female" "male"

Code: Select all

default gender = "male"
for example.

You wouldn't need two variables (like your example "you_male") (well unless you were just using that one and having it true or false and not a you_female one as well)

as far as what happens after that, you can use if statements.

Code: Select all

if gender == "male":
    #do something
else:
    #do something else (or if "female")
as far as assigning the variable as a name (My Lady, Miss, My Lord etc) after the player chooses male or female, you can then assign a name variable to a string of your choice in the same way you did this variable and use that variable in the dialogue

If you were using a true/false boolean you can also use the syntax

Code: Select all

if you_male:
    #do something
else:
    #etc

Code: Select all

"Nice to meet you [thename]." 
etc.

Have the variable defined before a label starts with the default statement as shown above.

As for the actual choice part, you can use menus inside a label.

Code: Select all

"Select your gender."
menu:
    "Male":
        $ gender = "Male"
    "Female":
        $ gender = "Female"
"The story continues"
    
Keep in mind that one = is assigning a variable. a double == is to check if a variable is equal to a value.

Post Reply

Who is online

Users browsing this forum: barsunduk, Majestic-12 [Bot]