Player gender and custom pronouns, changeable on settings
Posted: 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):
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 in there.
Next, in screens.rpy, dd this to your preferences screen:
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:
Right now, it looks like the confirm screen.
Add this code anywhere, it can be in the script.rpy file if you want:
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:
If anyone has a way to better this code, please say it and I'll update it here!
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 = FalseCode: Select all
default kid = "kid"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:
passStill 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")]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"
returnFinally, 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!"