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
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.
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”>>
<>
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.
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:
$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.
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:
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.