I like your solution the best, @cup_half_empty - thank you!
I’ve written my first game, spread across three files. I’m a programmer first, an author second. I’m finding ChoiceScript is a rudimentary programming language; it reminds me of my first programming language in 1979, Basic. Not Visual Basic. Just Basic.
First, startup.txt:
*comment If you change the list of characters, then remember to change char_num
*create char_name_1 "Dave"
*create char_gender_1 "male"
*create char_name_2 "Lisa"
*create char_gender_2 "female"
*create char_name_3 "Max"
*create char_gender_3 "non-binary"
*create char_name_4 "Lynn"
*create char_gender_4 "female"
*create char_name_5 "Lee"
*create char_gender_5 "non-binary"
*create char_name_6 "Charles"
*create char_gender_6 "male"
*create char_num 6
*create generated_word ""
*comment ********** START **********
*gosub_scene characters
*goto STOP
*label STOP
*line_break
[b]Bye-bye! THIS IS THE END![/b]
*line_break
*ending
Second, here what is in characters.txt:
*temp they_ ""
*temp them_ ""
*temp themself_ ""
*temp theirs_ ""
*temp their_ ""
*temp gender ""
*temp end_verb
*temp index 1
[b]There will be ${char_num} characters[/b].
*page_break
*comment Top of the loop is here:
*label character_loop
*set gender char_gender[index]
*gosub_scene utils gen_3rdperson_sing_word "sub" gender
*set they_ generated_word
*gosub_scene utils gen_3rdperson_sing_word "obj" gender
*set them_ generated_word
*gosub_scene utils gen_3rdperson_sing_word "pos" gender
*set theirs_ generated_word
*gosub_scene utils gen_3rdperson_sing_word "det" gender
*set their_ generated_word
*gosub_scene utils gen_3rdperson_sing_word "ref" gender
*set themself_ generated_word
*set end_verb "s"
*if (gender = "non-binary")
*set end_verb ""
Character #${index}
*line_break
$!{char_name[index]} gets up early for work.
Grabbing a hot coffee from the food truck outside ${their_} apartment, ${they_} head${end_verb} into ${their_} job.
"Crap," ${they_} mutter${end_verb} to ${themself_} as ${they_} see${end_verb} the last train pull out of the station.
$!{they_} run${end_verb} for the bus and just barely make${end_verb} it.
At the office, ${their_} boss yells at ${them_} for being late [i]again[/i] and tells ${them_} to clear out ${their_} desk.
Well, at least the coffee is still ${theirs_}.
*page_break
*set index +1
*if ( index <= char_num )
*goto character_loop
*else
*goto after_character_loop
*label after_character_loop
*comment Return from characters subroutine
*return
Finally, here’s what is in utils.txt:
*comment param_1 is type (sub, obj, ref, pos, det)
*comment param_2 is gender (male, female, non-binary)
*comment RETURN VALUE: Unfortunately, subroutines do not seem to be able to return a value
*comment This subroutine assumes the variable
*comment "generated_word" exists, and puts the return value there.
*comment In other words, this subroutine has a side-effect. Bleck. I prefer functional programming languages.
*label gen_3rdperson_sing_word
*params type temp_gender
*if (temp_gender = "male" )
*if (type = "sub")
*set generated_word "he"
*return
*if(type = "obj")
*set generated_word "him"
*return
*if (type = "ref")
*set generated_word "himself"
*return
*if (type = "pos") or (type = "det")
*set generated_word "his"
*return
*comment If the type is not recognized, use the following as the default
*set generated_word "he"
*return
*if (temp_gender = "female")
*if (type = "sub")
*set generated_word "she"
*return
*if(type = "obj") or (type = "det")
*set generated_word "her"
*return
*if (type = "ref")
*set generated_word "herself"
*return
*if (type = "pos")
*set generated_word "hers"
*return
*comment If the type is not recognized, use the following as the default
*set generated_word "she"
*return
*if (temp_gender = "non-binary")
*comment I'm tempted to use tey, tem, temself, ters, and ter. But these are not in common use at this time.
*if (type = "sub")
*set generated_word "they"
*return
*if(type = "obj")
*set generated_word "them"
*return
*if (type = "ref")
*set generated_word "themself"
*return
*if (type = "pos")
*set generated_word "theirs"
*return
*if (type = "det")
*set generated_word "their"
*return
*comment If the type is not recognized, use the following as the default
*set generated_word "they"
*return
*set generated_word "ERROR"
*return