Player gender and custom pronouns, changeable on settings

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
Saa
Regular
Posts: 32
Joined: Tue Aug 20, 2013 7:11 pm
Tumblr: nipahgirl
Contact:

Player gender and custom pronouns, changeable on settings

#1 Post by Saa »

Hi! This code makes it so the player can choose their gender and pronouns both on game start and any time in the settings. It also has an option to use custom pronouns.

First, initialize the variables (put them at the start of a file, like options.rpy):

Code: Select all

default MCname = "You"

default MCgender = "nonbinary"
default person = "person"
default sweetheart = "sweetheart"
default spouse = "spouse"

default MCpronouns = "they/them"
default theyare = "they are"
default they = "they"
default them = "them"
default their = "their"
default themselves = "themselves"
default plural = True

default tempname = MCname
default tempsub = they
default tempob = them
default tempposs = their
default tempref = themselves
default tempplu = plural

default pronquestion = False
default selpron = False
default selgen = False
You'll have to add each new variable to this initialization. So if you, say, want to add a word like "girl", you'll have to add a

Code: Select all

default kid = "kid"
in there.

Next, in screens.rpy, dd this to your preferences screen:

Code: Select all

if selgen == True:
                    vbox:
                        style_prefix "radio"
                        label _("Gender")
                        textbutton _("Male") action [Function(dgender, "guy"), SetVariable("MCgender", "male")]
                        textbutton _("Female") action [Function(dgender, "gal"), SetVariable("MCgender", "female")]
                        textbutton _("Nonbinary") action [Function(dgender, "nb"), SetVariable("MCgender", "nonbinary")]
                else:
                    pass
                if selpron == True:
                    vbox:
                        style_prefix "radio"
                        label _("Pronouns")
                        textbutton _("He/Him") action [Function(dpronouns, "he"), SetVariable("they", "he")]
                        textbutton _("She/Her") action [Function(dpronouns, "she"), SetVariable("they", "she")]
                        textbutton _("They/Them") action [Function(dpronouns, "they"), SetVariable("they", "they")]
                        textbutton _("Custom") action [Show("cpron"), Show("bsub"), Show("bob"), Show("bposs"), Show("bref")]
                else:
                    pass
The button for the objective pronoun is called bob, so you might want to change its name if you have a character named Bob and might name a screen after him.

Still in screens.rpy, add the custom pronoun screen:

Code: Select all

## Pronouns screen ##############################################################

screen cpron():

    modal True

    zorder 100

    style_prefix "cpron"

    add "gui/overlay/confirm.png"

    frame:

        vbox:
            xalign .5
            yalign .5
            spacing 30

            label _("Custom Pronouns:"):
                style "cpron_prompt"
                xalign 0.5
            hbox:
                vbox:
                    text "Subjective: "
                    text "Objective: "
                    text "Possessive: "
                    text "Reflexive: "
                vbox:
                    xsize 150
                    
            hbox:
                style_prefix "radio"
                textbutton _("Singular") action SetVariable("tempplu", False)
                textbutton _("Plural") action SetVariable("tempplu", True)
            hbox:
                textbutton _("Ok") action [Function(cpronouns, tempsub.strip(), tempob.strip(), tempposs.strip(), tempref.strip(), tempplu), Hide("cpron"), Hide("bsub"), Hide("bob"), Hide("bposs"), Hide("bref")]
                if pronquestion==True:
                    textbutton _("Cancel") action [Hide("cpron"), Hide("bsub"), Hide("bob"), Hide("bposs"), Hide("bref"), Jump("pronques")]
                else:
                    textbutton _("Cancel") action [Hide("cpron"), Hide("bsub"), Hide("bob"), Hide("bposs"), Hide("bref")]

    key "game_menu" action Hide("cpron")


style cpron_frame is gui_frame
style cpron_prompt is gui_prompt
style cpron_prompt_text is gui_prompt_text
style cpron_button is gui_medium_button
style cpron_button_text is gui_medium_button_text

style cpron_frame:
    background Frame([ "gui/confirm_frame.png", "gui/frame.png"], gui.confirm_frame_borders, tile=gui.frame_tile)
    padding gui.confirm_frame_borders.padding
    xalign .5
    yalign .5

style cpron_prompt_text:
    text_align 0.5
    layout "subtitle"
style cpron_promtex:
    line_leading 7
style cpron_button:
    properties gui.button_properties("cpron_button")

style cpron_button_text:
    properties gui.button_text_properties("cpron_button")

style cpron_hbox:
    xalign 0.5
    spacing 100
screen isub:
    button xysize(1280, 720) keysym "K_RETURN" action [Hide("isub"), Show("bsub")]
    zorder 115
    input value VariableInputValue("tempsub") length 6 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '-" xpos 0.541 ypos 0.365
screen iob:
    button xysize(1280, 720) keysym "K_RETURN" action [Hide("iob"), Show("bob")]
    zorder 115
    input value VariableInputValue("tempob") length 6 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '-" xpos 0.541 ypos 0.411
screen iposs:
    button xysize(1280, 720) keysym "K_RETURN" action [Hide("iposs"), Show("bposs")]
    zorder 115
    input value VariableInputValue("tempposs") length 6 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '-" xpos 0.541 ypos 0.456
screen iref:
    button xysize(1280, 720) keysym "K_RETURN" action [Hide("iref"), Show("bref")]
    zorder 115
    input value VariableInputValue("tempref") length 12 allow "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '-" xpos 0.541 ypos 0.502
screen bsub:
    zorder 110
    textbutton [tempsub] style "promtex" xpos 0.541 ypos 0.365 action [Show("isub"), Hide("bsub")]
screen bob:
    zorder 110
    textbutton [tempob] style "promtex" xpos 0.541 ypos 0.411 action [Show("iob"), Hide("bob")]
screen bposs:
    zorder 110
    textbutton [tempposs] style "promtex" xpos 0.541 ypos 0.456 action [Show("iposs"), Hide("bposs")]
screen bref:
    zorder 110
    textbutton [tempref] style "promtex" xpos 0.541 ypos 0.502 action [Show("iref"), Hide("bref")]
Right now, it looks like the confirm screen.

Add this code anywhere, it can be in the script.rpy file if you want:

Code: Select all

init python:
    def dpronouns(pronouns):
        global MCpronouns
        global theyare
        global they
        global them
        global their
        if pronouns == "she":
            MCpronouns = "she/her"
            theyare = "she is"
            they = "she"
            them = "her"
            their = "hers"
            themselves = "herself"
            plural = False
        if pronouns == "he":
            MCpronouns="he/him"
            theyare = "he is"
            they = "he"
            them = "him"
            their = "his"
            themselves = "himself"
            plural = False
        if pronouns == "they":
            MCpronouns = "they/them"
            theyare = "they are"
            they = "they"
            them = "them"
            their = "their"
            themselves = "themselves"
            plural = False
        return
        
    def cpronouns(sub, ob, poss, ref, plu):
        global MCpronouns
        global theyare
        global they
        global them
        global their
        global cpron
        MCpronouns = sub+"/"+ob
        if plu:
            theyare = sub+" are"
        else:
            theyare = sub+" is"
        they = sub
        them = ob
        their = poss
        themselves = ref
        cpron = True
        return
    
    def dgender(gender):
        global MCgender
        global person
        if gender == "guy":
            MCgender = "male"
            person = "man"
            sweetheart = "boyfriend"
            spouse = "husband"
            parent = "father"
        if gender == "gal":
            MCgender = "female"
            person = "woman"
            sweetheart = "girlfriend"
            spouse = "wife"
            parent = "mother"
        if gender == "nb":
            MCgender = "nonbinary"
            person = "person"
            sweetheart = "sweetheart"
            spouse = "spouse"
            parent = "parent"
        return
Back to the "girl" example, if you want to add a word, you'll have to add something like kid = "boy" under gender=="guy", kid = "girl" under gender=="gal", and kid = "kid" under gender=="nb".

Finally, an example of a script:

Code: Select all

e "Oh yeah, before I say anything: what are your pronouns?"
label pronques:
menu:
    "What are your pronouns?"
    "He/Him":
        $ dpronouns("he")
        jump pronouns_done
    "She/Her":
        $ dpronouns("she")
        jump pronouns_done
    "They/Them":
        $ dpronouns("they")
        jump pronouns_done
    "Other Pronouns":
        $ pronquestion = True
        show screen bsub
        show screen bob
        show screen bposs
        show screen bref
        show screen cpron
        jump pronouns_done
label pronouns_done:
$ selpron = True
e "Great! And what's your gender, again?"
menu:
    "Are you male or female?"
    "Male":
        $ dgender("guy")
        jump gender_done
    "Female":
        $ dgender("gal")
        jump gender_done
    "No":
        $ dgender("nb")
        jump gender_done
label gender_done:
$ selgen = True
e "So your pronouns are [MCpronouns] and you're [MCgender], right? Alright, let's go!"
If anyone has a way to better this code, please say it and I'll update it here!
Attachments
Screenshot_1.png

User avatar
parttimestorier
Veteran
Posts: 429
Joined: Thu Feb 09, 2017 10:29 pm
Completed: No Other Medicine, Well Met By Moonlight, RE:BURN, The Light at the End of the Ocean, Take A Hike!, Wizard School Woes
Projects: Seeds of Dreams
itch: janetitor
Location: Canada
Contact:

Re: Player gender and custom pronouns, changeable on settings

#2 Post by parttimestorier »

This is really cool! I've been wondering about a good way to implement custom pronouns. Thanks for sharing!
ImageImageImage

User avatar
cuterobot
Newbie
Posts: 3
Joined: Wed May 29, 2019 11:55 pm
Projects: I ordered a cute child robot
Contact:

Re: Player gender and custom pronouns, changeable on settings

#3 Post by cuterobot »

Cool, I did something similar for a character who isn't the player character. Since I talk about them in third person a lot... verbs have to match too. So for example:
if gender == "guy":
verb = "s"
verbe = "es"
if gender == "gal":
verb = "s"
verbe = "es"
if gender = "nb":
verb = ""
verbe = ""

[they] lift[verb] [their] arms.
[they] go[verbe] to the store.

he lifts his arms / she lifts her arms / they lift their arms.
he goes to the store / she goes to the store / they go to the store.

I have capitalized versions too. And I did some searching and found "themself" is commonly used and went with it.

User avatar
Andredron
Miko-Class Veteran
Posts: 697
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Player gender and custom pronouns, changeable on settings

#4 Post by Andredron »

Another example how to prescribe an image of a short code for different genders

viewtopic.php?p=498283#p498283

And

viewtopic.php?p=476350#p476350

User avatar
zeebly
Newbie
Posts: 3
Joined: Tue Jun 11, 2019 6:18 pm
Location: USA
Contact:

Re: Player gender and custom pronouns, changeable on settings

#5 Post by zeebly »

Been looking for something like this everywhere, thank you

Kagutaba
Newbie
Posts: 1
Joined: Thu Dec 05, 2019 7:27 am
Projects: SOI:O
Contact:

Re: Player gender and custom pronouns, changeable on settings

#6 Post by Kagutaba »

I know I'm a bit late to the party with this one but I'm currently writing a game that allows you to choose pronouns.

It's a bit more straightforward than the methods above, and might not necessarily be considered "right," but it works for me, so...
I started the script with my default pronouns like so

Code: Select all

default Her = "Her"
default Her2 = "Her"
default her = "her"
default her2 = "her"
default She = "She"
default she = "she"
default Hers = "Hers"
default hers = "hers"
default Herself = "Herself"
default herself = "herself"
and later on, when one of my characters asks how you'd like to be addressed, my code looks like this

Code: Select all

[...]
        k "Now then."
        k "How would you like to be addressed?"
        jump pronouns

label pronouns:
        menu:
            "They/Them/Theirs":
                $ Her = "Them"
                $ her = "them"
                $ Her2 = "Their"
                $ her2 = "their"
                $ Hers = "Theirs"
                $ hers = "theirs"
                $ She = "They"
                $ she = "they"
                $ Herself = "Themself"
                $ Herself2 = "Themselves"
                $ herself = "themself"
                $ herself2 = "themselves"
                jump pronouned
            "She/Her/Hers":
                pass
                jump pronouned
            "He/Him/His":
                $ Her = "Him"
                $ her = "him"
                $ Her2 = "Him"
                $ her2 = "him"
                $ Hers = "His"
                $ hers = "his"
                $ She = "He"
                $ she = "he"
                $ Herself = "Himself"
                $ herself = "himself"
                $ Herself2 = "Himself"
                $ herself2 = "himself"
                jump pronouned
            "Xe/Xyr/Xeirs":
                $ Her = "Xyr"
                $ her = "xyr"
                $ Her2 = "Xyr"
                $ her2 = "xyr"
                $ Hers = "Xyrs"
                $ hers = "xyrs"
                $ She = "Xe"
                $ she = "xe"
                $ Herself = "Xirself"
                $ herself = "xirself"
                $ Herself2 = "Xirself"
                $ herself2 = "xirself"
                jump pronouned
that way, later on in the game, I can just type in

Code: Select all

[She] will be coming to the party tomorrow
and it will automatically substitute whatever the player selected.

obviously, it doesn't grammatically make sense all the time with they/them, but if that's the case all it would take would be a simple adjustment to the coding under the "they/them" menu selection (and adding a default value for pronoun at 0 somewhere in your coding)

Code: Select all

$ pronoun += 1
then creating dialogue like so

Code: Select all

if pronoun==1
                k "They need to go answer the door."
else
                k "[She] needs to go answer the door."
I'm personally not dedicated enough to go through and identify verbs and everything, but i really do appreciate how simple and effective cuterobot's idea is!!
i hope this helps someone out!

User avatar
sheetcakeghost
Veteran
Posts: 383
Joined: Sat Sep 19, 2009 9:19 pm
Contact:

Re: Player gender and custom pronouns, changeable on settings

#7 Post by sheetcakeghost »

I've been doing something similar to this and was hoping to find someone who's worked out how to add it into a menu for mid game changes. The thing is, for style I've been writing the narrative in third person POV so I needed a lot more pronoun options to keep things grammatically correct.

Code: Select all

    menu:
        "Masculine":
            $ mcmale = True
            $ he="he"; him="him";his="his";phis="his";himself="himself"
            $ He="He"; Him="Him";His="His";Phis="His";Himself="Himself"
            r "Noted! Thank you."
            jump setupgri

        "Feminine":
            $ mcfemale = True
            $ he="she"; him="her";his="her";phis="hers";himself="herself"
            $ He="She"; Him="Her";His="Her";pHis="Hers";Himself="Herself"
            r "Noted! Thank you."
            jump setupgri

        "Spivak":
            $ mcother = True
            $ he="e"; him="em";his="eir";phis="eirs";himself="emself"
            $ He="E"; Him="Em";His="Eir";pHis="Eirs";Himself="Emself"
            r "Noted! Thank you."
            jump setupgri
        "Other":
            $ mcother = True
            $ mcchosepronouns = True
            r neutral "Please type your preferred pronouns into the tap pad."
            $ he = renpy.input("3rd Person Singular Subject Pronoun Ex: he, she, e, they, etc.")
            $ he = he.strip()
            if he == "":
                $ he="e"
            r "Due to case sensitive programming limitations, please re-enter the selected pronoun but capitalized."
            mct "Case sensitive what now? Oh well, let's just get this over with."
            $ He = renpy.input("3rd Person Singular Subject Pronoun Ex: He, She, E, They, etc.")
            $ He = He.strip()
            if He == "":
                $ He="E"
            r happy "You want \"[he]\"? Okay!"

            show r neutral
            $ him = renpy.input("3rd Person Singular Object Pronoun Ex: him, her, em, them, etc.")
            $ him = him.strip()
            if him == "":
                $ him="em"
#            pw "Due to case sensitive programing limitations, please re-enter the selected pronoun but capitalized."
#            mc "Am I going to have to do this every time? Yeesh."
#            $ Him = renpy.input("3rd Person Singular Object Pronoun Ex: Him, Her, Em, Them, etc.")
#            $ Him = Him.strip()
#            if Him == "":
#                $ Him="Em"
            r happy "You want \"[him]\"? No problem!"

            show r neutral
            $ his = renpy.input("3rd Person Singular Possessive Adjective Ex: his, her, eir, their, etc.")
            $ his = his.strip()
            if his == "":
                $ his="eir"
#            pw "Due to case sensitive programing limi-"
#            mc "Yeah, yeah, I got it. Capitalized."
#            $ His = renpy.input("3rd Person Singular Possessive Adjective Ex: His, Her, Eir, Their, etc.")
#            $ His = His.strip()
#            if His == "":
#                $ His="Eir"
            r happy "You want \"[his]\"? Excellent!"

            show r neutral
            $ phis = renpy.input("3rd Person Singular Possessive Pronoun Ex: his, hers, eirs, theirs, etc.")
            $ phis = phis.strip()
            if phis == "":
                $ phis="eirs"
#            pw "Due to case sensitive programing limi-"
#            mc "Yeah, yeah, I got it. Capitalized."
#            $ pHis = renpy.input("3rd Person Singular Possessive Pronoun Ex: His, Hers, Eirs, Theirs, etc.")
#            $ pHis = pHis.strip()
#            if pHis == "":
#                $ pHis="Eirs"
            r happy "You want \"[phis]\"? Okay! Last one!"
            mc "{i}Finally.{/i}"

            show r neutral
            $ himself = renpy.input("3rd Person Singular Intensive/Reflexive Pronoun Ex: himself, herself, itself, themself, etc.")
            $ himself = himself.strip()
            if himself == "":
                $ himself="emself"
#            pw "Due to-"
#            mc "I got it! Capitalized!"
#            $ Himself = renpy.input("3rd Person Singular Intensive/Reflexive Pronoun Ex: Himself, Herself, Itself, Themself, etc.")
#            $ Himself = Herself.strip()
#            if Himself == "":
#                $ Himself="Emself"
            r happy "You want \"[himself]\"? Sure thing!"
            jump setupgri

Post Reply

Who is online

Users browsing this forum: No registered users