Assigning NPC Pronouns

Twine Version: 2.3.14_win
Story Format: Sugarcube 2.34.1

I’m working on my first interactive fiction game and there are three characters I would like to be gender selectable. Right now this is the code I am using, I am wanting to use a dropdown or listbox for pronoun selection, similar to The Nameless by Parker Lyn. Any sort of help would be very much appreciated. Also a way to change the pronoun in the story, I’ve tried other methods but I don’t know if I’m implementing it wrong or not… like I said this is my first project

<<listbox “$variable”>>
<<option “He/Him” “He” $variable == "He" ? "selected" : "">>
<<option “She/Her” “She” $variable == "She" ? "selected" : "">>
<<option “They/Them” “They” $variable == "They" ? "selected" : "">>
<>

You might want to check out the “Pronoun Templates” section of my Twine/SugarCube sample code collection. That shows you how to use a <<SetGender>> macro and some specific templates to make your text display the gender that you currently have your pronouns set to use.

Hope that helps! :slight_smile:

I’ve already tried that I might be implementing it wrong tho…

You’ll have to be a bit more specific about what you’re trying and what isn’t working before we can help then.

apologies im not very good at writing from my brain to actual words basically im wondering what the format should be for it to work? and to implement it?
these is what ive tried so far:
<<listbox “$variable1”>>
<<option “He/Him” “He” $variable1 == "He" ? "selected" : "" >><>
<<option “She/Her” “She” $variable1 == "She" ? "selected" : "">><<SetPronouns “f”>>
<<option “They/Them” “They” $variable1 == "They" ? "selected" : "">><<SetPronouns “b”>>
<>

<<listbox “$variable1”>>
<<option “He/Him” “He” $variable1 == "He" ? "selected" : "" SetPronouns>>
<<option “She/Her” “She” $variable1 == "She" ? "selected" : "" SetPronouns “f”>>
<<option “They/Them” “They” $variable1 == "They" ? "selected" : "" SetPronouns “b”>>
<>

and then i call $variable1 when i want to call what im using so if i have the character selected to he/him im doing this

?$variable1 blah blah blah

basically what im asking is how to implement it correctly?

Please use the </> Preformatted text option, that is found in the Comment Field’s Toolbar, when including code examples in your posts. It makes them easier to read, stops the forum’s software removing things like the end tags of your macro calls, and more importantly stops that software from converting valid Standard quotes into invalid Typographical (curvy) quotes.

<<listbox "$variable1">>
	<<option "He/Him"	 "He"	($variable1 == "He" ? "selected" : "")>>
	<<option "She/Her"	 "She"	($variable1 == "She" ? "selected" : "")>>
	<<option "They/Them" "They"	($variable1 == "They" ? "selected" : "")>>
<</listbox>>

You are trying to mix the <<setPronouns>> widget of HiEv’s Pronoun Templates implementation directly with the <<listbox>> macro’s child <<option>> calls , and that wont work because the <<listbox>> macro has no knowledge of the <<setPronouns>> widget.

You would need to place the <<setPronouns>> widget calls behind another interactive component ( like a <<button>>) which would be used to call the widget after the Reader has selected which Pronoun set they want to use.

<<button "Update Pronouns">>
	<<if $variable1 is "He">><<SetPronouns "m">>
	<<elseif $variable1 is "She">><<SetPronouns "f">>
	<<else>><<SetPronouns "b">>
	<</if>>
<</button>>

ok! thank you! now i am wondering how to implement it? would i still use the $variable1? or how would i do that? I’m sorry for all of my questions sometimes coding can get very confusing for me ;_;

Not sure why Greyelf suggested doing it that way (or why he incorrectly capitalized my name), but if you want to have the listbox work with my pronoun templates, then the listbox to select the gender to be used should be done like this:

<<listbox "$pgen" autoselect>>
	<<option "He/Him" 0>>
	<<option "She/Her" 1>>
	<<option "They/Them" 2>>
<</listbox>>

$pgen is the variable that the template uses, so this saves you the extra step of using a button or the like.

So, if you add the “Pronoun Templates” code to your game, plus the above listbox, then you’d just use it in your game’s text something like this:

?They then put ?their coat on the back on the chair
by ?their desk and prepared ?themself for work.

All of the words with the “?” in front will then be adjusted based on the $pgen value to use the appropriate pronoun, as described on the “Pronoun Templates” page.

Hopefully that clears things up! :slight_smile:

ok that is working! but only for one… i have three characters to set for example this is what i have on the selection page

In this game you will be able to choose your gender and pronouns.
<<link 'Please click here to configure pronouns and gender.'>>
    <<pronouns>>
<</link>>
Ashley
<<listbox "$pgen" autoselect>>
	<<option "He/Him" 0>>
	<<option "She/Her" 1>>
	<<option "They/Them" 2>>
<</listbox>>
Daireann
<<listbox "$pgen" autoselect>>
	<<option "He/Him" 0>>
	<<option "She/Her" 1>>
	<<option "They/Them" 2>>
<</listbox>>>
Vian
<<listbox "$pgen" autoselect>>
	<<option "He/Him" 0>>
	<<option "She/Her" 1>>
	<<option "They/Them" 2>>
<</listbox>>

when it prints out it its only using the player pronouns the code i am using for the player pronouns is

i apologize if i am simply ‘not getting’ this my brain gets very confused sometime thank you for helping me

Ah. You didn’t mention that you needed to use this for more than one character. You can’t track three different things with only a single number variable like that.

Also, you’re using the wrong pronoun code for what I’ve been describing. Again, you need to add the code from the “Pronoun Templates ” sample code to your game for the code I’m giving you to work. You can’t just stick any random pronoun code in and expect it to work the same way. Chapel’s pronoun templates do NOT work the same way that mine do.

Anyways, you’ll need to use variables for each characters’ gender, and then change the current gender to be used whenever a new person is going to be referred to by pronouns. Thus, you’ll have to have the player select each characters’ pronouns something like this:

<label for="listbox-ash">''Ashley:''</label>
<<listbox "$Ash" autoselect>>
	<<option "He/Him" "m">>
	<<option "She/Her" "f">>
	<<option "They/Them" "b">>
<</listbox>>

<label for="listbox-dair">''Daireann:''</label>
<<listbox "$Dair" autoselect>>
	<<option "He/Him" "m">>
	<<option "She/Her" "f">>
	<<option "They/Them" "b">>
<</listbox>>>

<label for="listbox-vian">''Vian:''</label>
<<listbox "$Vian" autoselect>>
	<<option "He/Him" "m">>
	<<option "She/Her" "f">>
	<<option "They/Them" "b">>
<</listbox>>

Then, when you’re displaying text, you’ll need to do something like this:

<<SetGender $Ash>>Ashley then put ?their coat on the back on the chair
by ?their desk and prepared ?themself for work.

<<SetGender $Dair>>Daireann grabbed ?their own chair and slid it up to the
desk to join <<SetGender $Ash>>?them.

Calling the <<SetGender>> widget with the variable set by those listboxes will cause the pronoun templates which follow to use the gender selected from those listboxes. Simply call <<SetGender>> as needed in order to switch to the pronouns used by that character in the pronoun templates which follow.

Hopefully that all makes sense now! :slight_smile:

Yes! that works! thank you very much! im sorry for not understanding much but you helped me a lot thank you so much!

No problem, nobody is born knowing this stuff. :slight_smile:

FYI - I just clarified a bit of the wording in my previous post, so you might want to re-read it if anything in it was a bit unclear before.

1 Like