Reader selecting Gender Help!

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
lightningburrito
Newbie
Posts: 13
Joined: Tue Feb 06, 2018 12:31 am
Soundcloud: Glormpy
Contact:

Reader selecting Gender Help!

#1 Post by lightningburrito »

Hi! I am a total ren'py noob and have no idea what i'm doing! Well I have a little idea, but thats besides the point! In the early stage of my game I want the player or reader to be able to select gender from 3 choices in the game, and I want the script to remember the players choice so if they choose male in certain dialogue it will use he him pronouns, same with girl, and neither. Below is a part of my code that is about selecting gender. Hopefully someone can help me and tell me how to make this happen! Thanks!

Code: Select all

    "You gaze into the mirror and see..."
    
menu:
    "A young highschool boy.":
        jump highschoolboy
    "A beautiful highschool girl.":
        jump highschoolgirl
    "Something else.":
        jump somethingelse
        
label highschoolboy:
    "You rake a hand through your wet hair and get dressed for the day."
    
    "You realize you wasted about several minutes staring in the mirror and rush to finish getting ready to school."
    
    "Getting to school early was the intial plan, as wanting to meet the teachers and staff beforehand. However, it seems like you'll have to settle for being on time."
 
    
    return
    
label highschoolgirl:
    "You rake a comb through your hair and decided to get dressed for the day."
    
    "You realize you wasted about several minutes staring in the mirror and rush to finish getting ready to school."
    
    "Getting to school early was the intial plan, as wanting to meet the teachers and staff beforehand. However, it seems like you'll have to settle for being on time."

    
    return
    
label somethingelse:
    "Labels were never really your thing. And quite frankly you didn't care what others thought about how you identify yourself."
    
    "You realize you wasted about several minutes staring in the mirror and rush to finish getting ready to school."
    
    "Getting to school early was the intial plan, as wanting to meet the teachers and staff beforehand. However, it seems like you'll have to settle for being on time."

    return
    
    # This ends the game.

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: Reader selecting Gender Help!

#2 Post by mitoky »

First declare the variables, make all you need and dont forget Huge and small letter versions!

Code: Select all

default gender = "male"
default he = "he"
default He = "He"
default him = "him"
default Him = "Him"
##etc....
And then let the choice decide the gender variable (for boy no changes needed)

Code: Select all

menu:
    "A young highschool boy.":
        jump thereveal
    "A beautiful highschool girl.":
        $ gender = "female"
        jump thereveal
    "Something else.":
        $ gender = "neutral"
        jump thereveal
Afterwards you simply check the gender ariable and change the others accordingly:

Code: Select all

label thereveal:

    if gender == "male":
        $ he = "he"
        $ He = "He"
        $ him = "him"
	$ Him = "Him"
        ##etc....

    elif gender == "female":
        $ he = "she"
        $ He = "She"
        $ him = "her"
	$ Him = "Her"
        ##etc....

    else:
        $ he = "they"
        $ He = "They"
        $ him = "them"
	$ Him = "Them"
        ##etc....
   
    
    if gender == "male":
        "You rake a hand through your wet hair and get dressed for the day."
    elif gender == "female":
        "You rake a comb through your hair and decided to get dressed for the day."
    else:
        "Labels were never really your thing. And quite frankly you didn't care what others thought about how you identify yourself."
    
    "You realize you wasted about several minutes staring in the mirror and rush to finish getting ready to school."
    "Getting to school early was the intial plan, as wanting to meet the teachers and staff beforehand. However, it seems like you'll have to settle for being on time."
 
For whole lines which have to be changed for the gender, you use if statement as above to check for the gender and write the right line accordingly for eveyone. Otherwise (For general dialogue), when writing he/she/they etc simply use the variable name and put it into []

Example: The "He" variable would be He/She/They deepening on gender.
So if you chose "female" in game and write "[He] is a very good friend!" it will appear as "She" etc.

I hope i could help (:

Post Reply

Who is online

Users browsing this forum: Google [Bot]