I was trying to find an efficient solution for managing pronouns for a number of characters in the game I’m working on and have decided to share my array-based solution.
The problem
If you have multiple gender selectable characters (including the player), you will end up declaring multiple variables to store each pronoun for each character: player_he, plater_his, npc_he, npc_his, npc2_he, npc2_his, etc. Which you will set in various parts of the game with things like:
*set player_he "he"
...
*set npc_he "she"
...
*set npc2_he "they"
This can become cumbersome and error-prone.
Solution
This solution assumes that you understand how to use arrays and have the latest version of ChoiseScript or CSIDE that has the *create_array command:
New in ChoiceScript: *create_array, *temp_array commands, *page_break_advertisement
This code is based on the Pronouns sample project from CSIDE written by Lynnea Glasser.
- Inside the startup file are going to declare a constant value for each gender we want to support:
*comment gender constants
*create kMale 1
*create kFemale 2
*create kNb 3
- We are going to create and initialize an array for each pronoun type
*comment pronoun arrays
*create_array he 3 "he" "she" "they"
*create_array him 3 "him" "her" "them"
*create_array his 3 "his" "her" "their"
*create_array hiss 3 "his" "hers" "theirs"
*create_array himself 3 "himself" "herself" "themself"
*comment This is for the 's' on the ends of verbs, as in "they walk"/"she walks".
*create_array s 3 "s" "s" ""
*comment This is for the 'es' on the ends of verbs, as in "they march"/"she marches".
*create_array es 3 "es" "es" ""
*comment These two are for contractions. Note that all versions of them have an apostrophe: "they're"/"she's".
*create_array re 3 "s" "s" "re"
*create_array ve 3 "s" "s" "ve"
*comment This variable can be used in case there are any irregular verbs, as in "they are" / "she is".
*create_array them 3 false false true
*comment boy/girl/child
*create_array boy 3 "boy" "girl" "child"
*comment man/woman/person
*create_array man 3 "man" "woman" "person"
*comment Mr./Miss/M*
*create_array title 3 "Mr." "Mrs." "M*"
- Declare variables for all your characters with selectable genders
*create playerGender 0
*create npcGender 0
- Set a character’s gender
Choose your gender
*fake_choice
# Male
*set playerGender kMale
# Female
*set playerGender kFemale
# Nonbinary
*set playerGender kNb
- Test it out
$!{he[playerGender]}${re[playerGender]} beaming widely as ${he[playerGender]} bow${s[playerGender]} and gracefully offer${s[playerGender]} you ${his[playerGender]} hand. You take it. You're lucky to have ${him[playerGender]} by your side.
How do I modify the solution to add custom pronouns?
- Add an extra gender constant in ascending order from the last constant (kNb was 3 and last)
*create kZer 4
- Modify the array pronoun sizes from 3 to 4 and add the 4th pronoun
*create_array he 4 "he" "she" "ze"
*create_array him 4 "him" "her" "zim"
...
And from here you can test it out like in the solution example, the only thing you have to change is to set the player gender to kZer. You can also let the player input their own pronouns with things like:
What is your he/she pronoun?
*input_text he[kZer]
With this approach, when you need to add a new character with a selectable gender, all you have to do is declare their gender variable, set it somewhere, then pick a pronoun when you need it from the array using their set gender index.
- in startup file
*create npc1_gender 0
*create npc2_gender 0
-in a game file somewhere
*set npc1_gender kFemale
*set npc2_gender kMale
-in game text somewhere
$!{he[npc1_gender]} clutched ${his[npc1_gender]} pearls witnessing the awesome power of arrays. $!{his[npc2_gender]} face melted shortly after.