Years ago, someone on the COG Discord (I think it was Chris_Conley; apologies if I’m mistaken) shared how to do pronouns with arrays and I’ve greatly preferred that method ever since.
Using the Nan example:
*create_array he 3 "he" "she" "they"
*create_array him 3 "him" "her" "them"
*create_array his 3 "his" "her" "their"
*create_array hes 3 "he's" "she's" "they're"
*create_array s 3 "s" "s" ""
*create_array is 3 "is" "is" "are"
*create nan 2
$!{he[nan]} blink${s[nan]}, then let${s[nan]} ${him[nan]}self be pulled in. Once ${hes[nan]} on solid ground, ${he[nan]} mutter${s[nan]} a sheepish "thanks."
That’s how I would do it if I were optimizing for readability.
In reality, as the only soul who has to maintain my projects’ code, I often prioritize other things over readability. *if
statements? Only as a last resort. ![:wink: :wink:](https://emoji.discourse-cdn.com/twitter/wink.png?v=12)
$!{E[stag]} examine${S[stag]} the faded photograph. "After @{stag Wynley|Hazelton|Corbinger}, @{stag=burke we studied together|I studied} at Tolfield.@{stag=burke "| That is where we met."} $!{E[stag]} pause${S[stag]}, placing the photograph back down on ${EIR[stag]} desk. "$!{E[burke]} was a @{((stag=MALE) and (burke=FEMALE)) close companion|friend}@{stag=burke , though I suspect ${E[burke]} wished we were something more|}."
I’ve vaguely thought about writing a guide to alternatives to *if
s, (tentatively titled Impractical ChoiceScripting: A Guide to Clearcutting Your If/Else Tree Forest and Other Questionable Coding Techniques to Miss the Forest for the Trees), but I can’t imagine it being remotely useful to, well, anyone.
There are a lot of funky names. In addition to snake_case
, there is SCREAMING_SNAKE_CASE
, kebab-case
, TRAIN-CASE
, lowerCamelCase
, UpperCamelCase
...
kebab-case
can’t be used in variable names, but it can be used in file names and label names.
I use it to tell crunch and fluff apart at a glance. If I see *gosub poker-win
, I know it is just showing a scene and coming back, while *gosub play_poker
is doing work behind the scenes.
I use SCREAMING_SNAKE_CASE
for variables I have to make coding easier, but that shouldn’t change value. E.g.,
*create height 1
*create VERY_SHORT 1
*create SHORT 2
*create AVERAGE 3
*create TALL 4
*create VERY_TALL 5
*rand height VERY_SHORT VERY_TALL
@{height>AVERAGE You're tall!|You're not tall!}
Makes them easier to understand, plus you can easily discover if you messed up by searching for *set (any capital letter)
.
Edit: even with all those words I didn’t get around to saying what I really like about the array method – you need a whole lot fewer variables.
Setting up a new gender-variable character is as easy as adding a single variable. Adding new gender-related words is as easy as a *create_array
command.
I’ve found it has let me do fun (for me) things like have characters with multiple pronoun sets or make very minor characters gender-randomized. If the player input custom pronouns (which I generally store at the 4th and 5th positions in the arrays), it’s easy to have other characters in the world use them.