Help again…[displaying text based on a variable in Twine]

I feel like I’m singly handily keeping the general help thread alive with how bad I’m consistently struggling. So for some reason my code is not doing the proper thing here is a picture the $person2 is supposed to show boy or girl depending on the gender but it doesn’t show instead it shows $person 2 I don’t think I have any coding or spelling wrong but I’m steadily losing my mind

Here’s my code for the scen as well as the play test part

As far as I can see you never set a variable called $person2; the variable that would display “boy” or “girl” is called $pronoun.

By the way, Chapel’s Custom Macro Collection has a pronoun template macro that would do some of this for you more efficiently; depending on the current state of this project, it might be a lot of work to incorporate it now, but for future reference, there it is.

(It’s easier for us to see/read the code properly if you copy/paste it here, with the Preformatted text formatting (CTRL+E or </> icon when you type your message))
Also, why have two $gender variable?

Shit wrong picture I posted the old one where I was still having the same issue. It’s currently says $person2 now

It’s how my brain works. Might seem a bit chaotic to some but it’s easier for me to code. And I’ll post that in one minute.

Inside of Twine I don’t think you can right click, but you can copy/paste between windows/browser with CTRL-C and CTRL-V.

That’s what we’re here for, don’t be concerned about asking for help!


Ok so here is the variable along with some of the text
care of the $person2.

then here is the big harry bit

<<if $peoplekind is "womankind">><<set $they to "she", $gender to "female", $them to "her", $gender2 to "woman", $person2 to "girl", $their to "her">><<elseif $peoplekind is "mankind">><<set $they to "he", $gender to "male", $gender2 to "man", $them to "him", $person2 to "boy", $their to "his">><</if>>

Just to be clear this is the only variable I am having issue with all the others seem to be working fine

If I paste in that code and set the $peoplekind variable, $person2 displays as it should for me.

:melting_face:I feel like I’m losing my mind with this then. It’s not working for me for some reason. I’ll check again tomorrow morning

Is the variable setting code on a regular passage and are you using the test from here functionality? If so, then that’s the problem. The passage where you’re setting those variables is being bypassed when using the test from here functionality, which jumps strings to playing the selected passage.

You could assign the variables default values in the StoryInit special passage, so they always have some values. It would probably be a good idea to differentiate those values in some way, so you don’t get confused down the line—e.g., setting $they to something like "(she)" so you know you’re seeing the default values.

1 Like

They seem to be setting all the gender-related variables at the same time, and you can see that “others will want to see $them soon” displays as “others will want to see her soon” in the pictures above, so I’m not sure that’s it.

Something else. You should not stack other text directly adjacent to naked variables. If you need to do so, then you’re better off wrapping the variable in one of the <<print>> macro variants. E.g.,

/* BAD */
… $person2's …

/* GOOD */
… <<= $person2>>'s …

I didn’t say that was the definitive issue—note the qualifications therein. It is a very common newbie mistake, however, so it deserves to be covered.


ok yeah retried and im still having the same issue and i have no idea why. I even changed the variable name and still having the same issue

its so weird to cause when I use one of my other variables it works no problem but this one just doesnt want to work

Did you look into MadExile’s suggestions at all? What happens if you wrap the naked variable in a <<print>> macro?

Did indeed and got [undefined] the crazy thing is is that all my other variables work when I put it in that place but not that one not even when i change the name

The only thing I can suggest at this point is to either provide the code or a compiled file. The problem is there somewhere, but without eyes on we’re limited to guessing.