Letting the player choose their pronouns?

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
deskbot
Newbie
Posts: 3
Joined: Sat Sep 09, 2017 2:18 am
Contact:

Letting the player choose their pronouns?

#1 Post by deskbot »

I'd like to be able to have the player choose their gender at the beginning of the game, along with some other character creation things. My question is, could I make it so that, for example, if the player chooses "male" when making their character, then every time the player character is referred to, the game uses "he/him" pronouns for them? Likewise, it would use "she/her" if they chose "female", and so on.

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Letting the player choose their pronouns?

#2 Post by RicharDann »

It is possible with a little Python programming, you might need to make a variable (or maybe a list) for every single possible combination of words, his, him, her, etc., minding upper and lower case as you write the script, it is doable but still a lot of work troublesome so most people use genderless nouns like "they" to refer to the main character. Still a simple way to do it it would be probably like this:

Code: Select all

# The game starts here.

default player_name = ""
default player_3rd_person_noun_up = ""
default player_3rd_person_noun_low = ""


label start:

    "First tell us your name."
    
    $ player_name = renpy.input("Please input your name.")
    
    menu:
        
        "Now choose a gender."
        
        "I'm Male.":
            $ player_3rd_noun_up = "His"
            $ player_3rd_person_noun_low = "his"
        "I'm Female.":
            $ player_3rd_noun_up = "Her"
            $ player_3rd_person_noun_low = "her"
            
    "[player_3rd_noun_up] name is [player_name]. I'm glad to be [player_3rd_person_noun_low] friend."
But of course it needs to be a lot more complicated than that.
Last edited by RicharDann on Fri Oct 06, 2017 12:07 pm, edited 2 times in total.
The most important step is always the next one.

User avatar
trekopedia
Regular
Posts: 25
Joined: Thu Sep 14, 2017 11:38 pm
Location: Toronto, Canada
Contact:

Re: Letting the player choose their pronouns?

#3 Post by trekopedia »

Sure. You could create a function that gets passed values reflecting the usage situation and it returns the appropriate string. For example, a simplistic example might be:

Code: Select all

def getPronoun(gender, case):
    if gender == 'Male' and case == 'Possessive':
        return 'his'
    if gender == 'Female' and case == 'Possessive':
        return 'her'
    if gender == 'Male' and case == 'Personal':
        return 'he'
    if gender == 'Female' and case == 'Personal':
        return 'she'
    if gender == 'Male' and case == 'Reflexive':
        return 'himself'
    if gender == 'Female' and case == 'Reflexive':
        return 'herself
You'd call this with something like:

Code: Select all

$ myPronoun = getPronoun("Female", "Reflexive")
You need to give careful thought to all the situations you need to address, though. English is notoriously difficult to generate programmatically.

Have fun!

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Letting the player choose their pronouns?

#4 Post by trooper6 »

I do it something like RicharDann's but in a way that works a bit more intuitively for me.

Code: Select all

default Her = "Her"
default her = "her"
default She = "She"
default she = "she"
default Hers = "Hers"
default hers = "hers"
default Herself = "Herself"
default herself = "herself"

label start:
    menu:
        "Which Gender?"
        "Male":
            $ Her = "His"
            $ her = "his"
            $ She = "He"
            $ she = "he"
            $ Herself = "Himself"
            $ herself = "herself"
        "Female":
            pass
        "Gender neutral":
            $ Her = "Them"
            $ her = "them"
            $ She = "They"
            $ she = "they"
            $ Herself = "Themself"
            $ herself = "themself"

    "Did you see [her]? [She] was driving [herself] to the hospital in Johnny's car. I wonder where [she] left [her] own car?"
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Letting the player choose their pronouns?

#5 Post by Remix »

The item was his
The item was hers
His item
Hers item ... you need one more swappable term...

Anyway, another option is to overload the say lexer or say screen and hot swap prefixed terms...

Lexer version:

Code: Select all

In a different file named '01say_lexer.rpy' or something starting 01 - definitely not in script.rpy

python early:

    swap_from = ['herself', 'hers', 'her', 'she']
    swap_to = ['herself', 'hers', 'her', 'she']

    def parse_smartline(lex):
        who = lex.simple_expression()
        what = lex.rest()
        return (who, what)

    def execute_smartline(o):
        who, what = o
        if not what or not len(what):
            who, what = None, who
        for index, key in enumerate( swap_from ):
            value = swap_to[ index ]
            what = what.replace( "*{0}".format(key), value)
            what = what.replace( "*{0}".format(key.capitalize()), value.capitalize())
        renpy.say(eval(who) if who else None, what)

    def lint_smartline(o):
        who, what = o
        if not what or not len(what):
            what = who
        else:
            try:
                eval(who)
            except:
                renpy.error("Character not defined: %s" % who)

        tte = renpy.check_text_tags(what)
        if tte:
            renpy.error(tte)

    renpy.register_statement("", parse=parse_smartline, execute=execute_smartline, lint=lint_smartline)
Screens version - screens.rpy
Probably easier

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:
        id "window"

        if who is not None:

            window:
                style "namebox"
                text who id "who"

        # add this bit
        python:
            for index, key in enumerate( swap_from ):
                value = swap_to[ index ]
                what = what.replace( "*{0}".format(key), value)
                what = what.replace( "*{0}".format(key.capitalize()), value.capitalize())

        text what id "what"


    ## If there's a side image, display it above the text. Do not display on the
    ## phone variant - there's no room.
    if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0
script.rpy sample

Code: Select all

# lexer version would not need defaults here
default swap_from = ['herself', 'hers', 'her', 'she']
default swap_to = ['herself', 'hers', 'her', 'she']

label start:
    "First Line"
    "I saw *her looking at *herself. *She looked *foxy"
    $ swap_to = ['himself', 'his', 'him', 'he']
    "*Her next move made me think. *She *hers *Herself *her doesn't cover everything."
    return
Frameworks & Scriptlets:

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Letting the player choose their pronouns?

#6 Post by Remix »

P.S. I wish you luck if you ever plan to translate your game to other languages... *shudders at the thought*
Frameworks & Scriptlets:

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Letting the player choose their pronouns?

#7 Post by Remix »

Another option, likely using string replacement like above is to use a function call set within config

Code: Select all

init python:
    def fix_pronouns( str_to_fix ):
        for index, key in enumerate( swap_from ):
            value = swap_to[ index ]
            str_to_fix = str_to_fix.replace( "*{0}".format(key), value)
            str_to_fix = str_to_fix.replace( "*{0}".format(key.capitalize()), value.capitalize())
        return str_to_fix

define config.say_menu_text_filter = fix_pronouns
Frameworks & Scriptlets:

beanieboy
Newbie
Posts: 3
Joined: Wed Nov 08, 2017 8:27 pm
Contact:

Re: Letting the player choose their pronouns?

#8 Post by beanieboy »

Right now if I use "they" in the ones above, I get something like "Did you see them? They was driving themself to the hospital in Johnny's car? I wonder where they left them own car?"

Would it be smoother to have "he"/"she" be one bit with the pronouns swapable and have "they" be its own manually changed sentence?

User avatar
MichiPantera
Newbie
Posts: 8
Joined: Thu Mar 23, 2017 12:04 pm
Contact:

Re: Letting the player choose their pronouns?

#9 Post by MichiPantera »

I don't know if this might sound crazy, but other alternative would be the following:

1. Duplicate the script written in only one gender (for example female) and put the copy in another script file.
2. Let the player choose gender with menu in script file 1. If female chosen just 'pass' and let it connect with the first copy of the script in the same script file. If male chosen 'jump' to the second script file where you have the second copy of the script.
3. Open second script file where you have the second copy of the script and using the tool 'Find' (Search, Find...), look for each pronoun form (her, hers, she, herself, etc..) and put the male equivalent in the 'Replace with' slot and push 'Replace All' and it will replace them all automatically. (see the picture attached) Make sure you write the word between spaces in order to isolate it from other words. (Don't forget capital letters, or beginning and ending with any kind of punctuation (?.!..))

It shouldn't take you more than 5 minutes to do the whole thing.
Captura de pantalla 2017-11-09 a las 11.47.56.png

User avatar
LateWhiteRabbit
Eileen-Class Veteran
Posts: 1867
Joined: Sat Jan 19, 2008 2:47 pm
Projects: The Space Between
Contact:

Re: Letting the player choose their pronouns?

#10 Post by LateWhiteRabbit »

beanieboy wrote: Wed Nov 08, 2017 8:34 pm Right now if I use "they" in the ones above, I get something like "Did you see them? They was driving themself to the hospital in Johnny's car? I wonder where they left them own car?"

Would it be smoother to have "he"/"she" be one bit with the pronouns swapable and have "they" be its own manually changed sentence?
If you were using 'they' to be gender neutral for the MC, you wouldn't phrase the sentence like that - of course it looks awkward when you structure it like that. Instead you'd write something like:
"Did you see them? They were driving to the hospital in Johnny's car. I wonder where they left their car?"

That is a perfectly natural sentence in English, is gender-neutral, and isn't awkward. And you can see why most authors who want to be gender-neutral with the MC choose to write this way, rather than getting heavy into code and alternate sentences.

Of course, I personally prefer MC's with predefined backstory and histories - whether the VN author wants to make them male, female, or non-binary doesn't matter to me. I don't feel the need to have an avatar or self-insert in the games I play or stories I read.

User avatar
deskbot
Newbie
Posts: 3
Joined: Sat Sep 09, 2017 2:18 am
Contact:

Re: Letting the player choose their pronouns?

#11 Post by deskbot »

I couldn't find anything about necro'ing threads in the rules, but forgive me if this is considered rude beyond the rules... well, in any case.

I technically wrote this in... April, I think? And the thread itself is very old, so I'm very much late, but I figured I might as well post it just in case anyone ends up looking at this thread while trying to figure out how to do the same thing I was. But here's what I ended up using:

Code: Select all

default Their = "Their"
default their = "their"
default Theirs = "Theirs"
default theirs = "theirs"
default They = "They"
default they = "they"
default Themself = "Themself"
default themself = "themself"
default Them = "Them"
default them = "them"
default Theyre = "They're"
default theyre = "they're"
default TheyWere = "They were"
default theyWere = "they were"

label start:
    
label choosepronoun:
    menu:
        "You feel like..."
        
        "You use 'he.'":
            $ Their = "His"
            $ their = "his"
            $ Theirs = "His"
            $ theirs = "his"
            $ They = "He"
            $ they = "he"
            $ Themself = "Himself"
            $ themself = "himself"
            $ Them = "Him"
            $ them = "him"
            $ Theyre = "He's"
            $ theyre = "he's"
            $ TheyWere = "He was"
            $ theyWere = "he was"
        "You use 'she.'":
            $ Their = "Her"
            $ their = "her"
            $ Theirs = "Her"
            $ theirs = "her"
            $ They = "She"
            $ they = "she"
            $ Themself = "Herself"
            $ themself = "herself"
            $ Them = "Her"
            $ them = "her"
            $ Theyre = "She's"
            $ theyre = "she's"
            $ TheyWere = "She was"
            $ theyWere = "she was"
        "You use 'they.'":
            pass

    "'I'm looking for [player_name]. Did you see [them]? [TheyWere] driving [themself] to the hospital in Johnny's car. I wonder where [they] left [their] own car?'"
    
    menu:
        
        "Is this right? This can't be changed later."
        
        "Yes.":
            return
            
        "No, let's try something else.":
            jump choosepronoun
It's just trooper6's code (thank you very much for your help) except using 'they' as the default, purely for anyone to copy-paste if they want to use it like this without having to do any editing.

I think this works a little easier for the purpose of switching the pronouns out later, since, for example, 'her' can be both possessive and objective case, so it gets sticky if you add pronouns whose spellings change in more cases (ex. they) while using it as your default. Plus a few extra values for contractions and additional words with the pronouns, since that changes with them as well for proper grammar. (no "they was driving themself" or "she were driving herself.")

Also, obviously you can add as many options as you want to add values for, and the extra stuff like the example sentences and menu options are changeable.
Last edited by deskbot on Tue Sep 29, 2020 10:46 am, edited 1 time in total.

Gouvernathor
Newbie
Posts: 23
Joined: Thu Aug 06, 2020 9:27 am
Github: Gouvernathor
Discord: Armise#6515
Contact:

Re: Letting the player choose their pronouns?

#12 Post by Gouvernathor »

I created a python-class system to implement a way to manage characters' pronouns and a bunch of other stuff, that you can use at your will <3
I (not quite humbly) think it works better than the systems I've seen here or in published projects.
It's over there at https://github.com/Gouvernathor/RenPron-class. The name is garbage but whatever.

Dr_arell
Regular
Posts: 70
Joined: Sun Feb 23, 2020 11:24 pm
Deviantart: DarellArt
Contact:

Re: Letting the player choose their pronouns?

#13 Post by Dr_arell »

i remember a guy asking the same question, the thing about gender specification is that causes some issues when translating, what i suggested the guy to do is to define 2 list of words one for male and one for female, and have a menu give the choice, depending on what the user choice is, the menu will set the variable to store the list for male or female.

menu:
"boy path"
$ g_words = {him, he, wizard, husband}

"girl path"
$ g_words = {her, she, witch, wife}


i went to the movies with %g_words1 and i love the way %g_words2 looked at me.

have in mind i'm lazy and this is not actually functional code, obviously dont try to run this XD.

another way to do it is just set everything manually in two different sub sets of the menu, but what a pain D:

thats the post from the guy and my answer, altough it is in spanish, its the same thing, basically calling elements from the list.
viewtopic.php?f=8&t=59318#p531124

User avatar
deskbot
Newbie
Posts: 3
Joined: Sat Sep 09, 2017 2:18 am
Contact:

Re: Letting the player choose their pronouns?

#14 Post by deskbot »

Gouvernathor wrote: Thu Aug 06, 2020 10:10 am I created a python-class system to implement a way to manage characters' pronouns and a bunch of other stuff, that you can use at your will <3
I (not quite humbly) think it works better than the systems I've seen here or in published projects.
It's over there at https://github.com/Gouvernathor/RenPron-class. The name is garbage but whatever.
ooh, this is really nice and efficient, thank you for sharing it! I'll have to keep it in mind and share it around.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Zodiac_Stories