Giving My NPCs Pronouns (as a definite)

I’m terribly sorry if this topic has already been discussed, and for this topic to be brought up so soon after my last one. The “as a definite” is supposed to be for it not being an option for the player, and, instead, the first choice is what defines whether they meet someone or not as either a boy or a girl. Basically, it’s not supposed to be a listbox, and it’s supposed to be chosen automatically.

I’m coding the same game as before, and I’ve run into an issue. I can’t seem to get the code to work. I used the topic Assigning NPC Pronouns, however, I couldn’t use it for my coding. It didn’t apply to what I was trying to do and wasn’t what I needed. I used HiEv’s pronoun template sample code, but I couldn’t understand it well. I copied and pasted the $pgen sample, but when I tried to use it in the first passages of the introduction to the character, it didn’t work. When you see the message “You see a… (boy or girl depending on the first choice in the game)”, the next passage is supposed to have it say, “She/He walks up to you”, and I used the “?They” variable. When I checked to see how it was running, it says, “<<$pgen = 0 $Rain>>” at the bottom. And, instead of it saying the “She/He walks up to you”, it says, “?They walks up to you”. I’m sorry if it’s easy to fix and I’m just not getting it, and I’m not sure if I can access this topic either, but I used the “preformatted text” option so it wouldn’t mess up the code. Thank you to anyone who replies, I appreciate it very much.

If you’re using my pronoun template, then you’ll probably need to call the <<SetGender>> widget initially somewhere to set the starting gender (it defaults to male). If the gender you need it to use has changed since the last time you used it, then you need to call the <<SetGender>> widget again first in order to change the gender that the templated words will use.

How you set up changing the gender when you need to is up to you, and should be decided based on how your game works. There’s nothing requiring you to set it using a listbox, that was merely given as an example for that particular question.

If you want the gender set with the first choice in the game, then you might do something like this in your first passage:

''You tell them:''
* <<link "I'm a guy." "Next passage">>
	<<set $gender = "m">>
	<<SetGender "m">>
* <<link "I'm a girl." "Next passage">>
	<<set $gender = "f">>
	<<SetGender "f">>

Now you will have the $gender story variable set up to track the gender chosen if you need it for any reason (my code doesn’t require it), and, if you have my pronoun template added to your game, the <<SetGender>> call will prime the pronoun template to use that gender in any subsequent passages.

If you’re seeing “?They walks up to you”, then I’m going to have to guess that you either did not add the code for my pronoun template to your game first, or you’re using a version of SugarCube which predates the addition of the Template API (this feature was added in SugarCube v2.29.0). You’ll need to follow the instructions from my page to add the needed JavaScript and widget code, and/or update your version of SugarCube (download link here, installation instructions here) and that should fix the problem.

Hopefully that helps, but if not, feel free to ask any other questions you have, but try to show simple versions of your actual code (within preformatted text blocks, like the above example) and let us know what version of SugarCube you’re using so we can have a bit better idea of what is going on.

1 Like