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.

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

44 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:

3 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.

4 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?

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.

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!

4 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 @HannahPS!!!

1 Like

Hannah thank you so much for putting that out there.

1 Like