Hide unspecified variable

Forgive the newbie question but I have a problem with hiding a user-input variable.

So, what I want to do is to create a passage that will contain player information about their character but only show variables after they are chosen. I managed to find a way for it to work with predefined names:

<<if $name is "John">>Your name is John.
<<elseif $name is "Jane">>Your name is Jane.
<<elseif $name is "">>Your name is $name. 

What is the variable name I need to put there for the text to show up only after the player chooses their own name via <<textbox "$name" "">>? Because as it is the passage just says “Your name is .” from the beginning of the game (understandable).

It’s driving me insane :sweat_smile:

I’m using:
Twine Version: 2.3.9
Story Format: Sugarcube 2.31.1

1 Like

As explained in the <<textbox>> macro’s documentation, the value you pass as the 2nd argument to the macro will become the default value of the referenced variable if no value is entered by the reader/player. In the above example you are passing an empty string ("") as the default value.

So if the variable equals that default value after you have finished displaying the textbox then the reader/player didn’t enter their own value, and you can use the <<if>> macro’s isnot operator to check if the variable is not equal to the above mentioned empty string ("") default value.

<<if $name isnot "">>Your name is $name.<</if>>
1 Like

Thank you so much! :slight_smile:

I am learning on the go and it’s such a trial by error sometimes…still, worth it :wink:

1 Like