Gender and Pronoun Sample Code

Hey everyone! I’ve made an example startup file for randomising or choosing NPC genders, and PC pronouns including entering pronouns.

You can find a playable version here and view the full txt file here.

There is also a newer version that uses ${npc_they}, ${npc_them} etc. It is playable here and the txt file can be viewed here.

Let me know if it’s useful, and if you’ve got any questions!

73 Likes

It is very useful and very much appreciated.

I’d like to cross-post your code links into the “It’s A Matter of Respect” with your permission. This code dovetails very nicely into that thread’s topic.

3 Likes

Please feel free to crosspost away! :blush:

4 Likes

You’re a god send! I was just wondering about how to do that. I’m afraid I’m god awful at programming. :sweat_smile:

4 Likes

Wow thank you so much @HannahPS Hannah, this is really helpful. :heart_eyes: :kissing_heart:
Perhaps we should dedicate a thread to code snippet archives, where we can post code snippets of how a special thing was handled. Since in programming sometimes you get something that works, but is bulky, if you could see how other people handled that, that might be helpful.

6 Likes

Thank you very much; You’re an awesome person. :smiley:

2 Likes

It’s a very nice piece of code. I was wondering if you would also need to set the possessive pronoun (eg. hers, theirs)

I originally thought I could write a game without using “hers” for the gender-variable characters. I was wrong – though to be fair, I made it a couple hundred thousand words in before I finally got sick of writing around it and added the variable.

4 Likes

Having variables for the pronouns is not too bad. What I find very tedious is dealing with plural/singular (she says/they say). Do you people use the multi replace? Do you write everything in the past tense (she did/they did)? What’s your approach?

2 Likes

Idk if this works for everyone, but in my code I just have a variable that’s like c_s, where it gets set to “” if the character is non-binary.

So, coding {c_he} say{c_s} yields he says OR they say.

2 Likes

Thanks @Goddess. That almost works, but it would give you “they fly/she flys” instead of “she flies”. I guess you can slightly change verb: “they escape/she escapes”

I do it similarly to @Goddess. There’s a character_singular variable that gets set to true or false depending on their gender. For example, in the sample code I’ve created a variable called freddie_singular - if Freddie’s pronouns are he/him or she/her, it’s set to true, and if it’s they/them, it’s set to false. Then in the text, this is how I do it, with multireplace:

When you meet Freddie, ${freddie_he} @{freddie_singular introduces|introduce} ${freddie_him}self.

like @Havenstone I tend to avoid it, but if it comes up in the writing, yes you would want to do that!

7 Likes

I’ve just written by own gender randomisation code and used this thread as inspiration. My need is a little different (and might be something others are interested in, so will post my code). I want to maintain an even split in genders across a pool of characters, in this example, 2 males and 2 females.

You can add other gender classifications and you’ll need to add the pronoun code on top as well, this is just the basic principle. You will also need to expand it for if you have more than 4 characters.

*temp Gender 0

*rand Gender 1 2

*if Gender = 1
    *set ExplorerGender "Male"
*if Gender = 2
    *set ExplorerGender "Female"
    
*rand Gender 1 2

*if Gender = 1
    *set ChefGender "Male"
*if Gender = 2
    *set ChefGender "Female"
    
*if ((ExplorerGender = "Male") and (ChefGender = "Male"))
    *set EntertainerGender "Female"
    *set DiplomatGender "Female"
    *return

*if ((ExplorerGender = "Female") and (ChefGender = "Female"))
    *set EntertainerGender "Male"
    *set DiplomatGender "Male"
    *return
    
*rand Gender 1 2

*if Gender = 1
    *set EntertainerGender "Male"
    *set DiplomatGender "Female"
    *return
*else
    *set EntertainerGender "Female"
    *set DiplomatGender "Male"
    *return

Essentially works on the premise that if the first two characters share the same gender, then the remaining two characters must be the other gender. Or if the first two differ, then whatever the third character comes out as, the fourth must be the opposite.

For more characters you ‘lock in’ point just moves (for odd numbers, you’ll just have to decide what to do with the odd one out).

For more than 2 genders then you’ll have to figure it out as I can’t be bothered (and if you aren’t sure how, just ask and I’ll sit and think on it) :slight_smile:

1 Like

THANK YOU @HarrisPS!!!

1 Like

Hannah thank you so much for putting that out there.

1 Like

I stumbled onto this from the pinned post Eiwynn made - so helpful, thank you for sharing!

2 Likes

@Arlo has also created sample code for multiple pronouns such as she/they, he/they and so on. Check it out over here!

2 Likes

I’ve done a small update to the original sample code to include an example of using a verb variable such as ${freddie_says} (which is set to “say” or “says” during the gender selection) rather than @{freddie_singular says|say}. This is quicker and reduces errors - hooray! (I can’t believe I had gone through three games with gender-selectable characters before my wife did this in her WIP and we both realised how much easier it would make things.)

I’ve also added a version which uses ${npc_they}/${npc_them} etc. This helps removes the need to mix variables using the different kinds of her/her or his/his, if such things bother you like they do me. It also makes it easier to spot mismatched verb agreements if players are testing the game with PCs/NPCs who use singular verbs (which is the most common configuration).

4 Likes

I’ve been following Lynnea Glasser’s approach, which is to rely mostly on s, es, re, and ve variables for a character who could use either singular or plural pronouns – so say/says becomes just another use of the s-variable, say${s}. Or say${f_s} for Freddie – when I have NPC-specific variables, I tend to type just one or two letters as an identifier, rather than their whole name.

I can see how the four-variable approach could get cumbersome the more of those characters you have in the game, though, and how just multireplacing a f_plural variable for Freddie’s verbs, with e.g. f_say for super-frequent verbs, would be an attractive alternative.

3 Likes

Yeah, I find it easier to type a whole word - it doesn’t feel quite as intuitive to have a dollar sign in the middle of the word like say${f_s}. Very much to personal taste though, of course!

What is weird is that I use ${npc_he} in Royal Affairs and ${npc_they} in Honor Bound and the change took a little getting used to but is now second nature. But when an old character from a previous game showed up as a cameo in Honor Bound, using ${npc_he}, it was a real bamboozling moment and I started accidentally using ${npc_he} for HB characters who have never used it. So, the lesson is that my muscle memory is very much like a sponge, and it’s better not to mix whatever method that’s been decided on. (Though I am very pleased with the decision to move to ${npc_they} - it’s been helpful for a number of reasons.

5 Likes