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 » Mon May 06, 2019 11:43 am

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: 288
Joined: Thu Feb 09, 2017 10:29 pm
Completed: No Other Medicine, Well Met By Moonlight, RE:BURN
Projects: DemiDato, The Light at the End of the Ocean
itch: janetitor
Location: Canada
Contact:

Re: Player gender and custom pronouns, changeable on settings

#2 Post by parttimestorier » Thu May 23, 2019 9:23 pm

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 » Thu May 30, 2019 1:27 am

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
Veteran
Posts: 340
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Player gender and custom pronouns, changeable on settings

#4 Post by Andredron » Thu May 30, 2019 2:33 am

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
I know, I'm writing terribly in English.

I'm writing a Renpy textbook (in Russian). https://yadi.sk/d/ZX_DonP63USRru Update 22.06.18

Honest Critique

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 » Tue Jun 11, 2019 6:31 pm

Been looking for something like this everywhere, thank you

Post Reply

Who is online

Users browsing this forum: No registered users