0 votes
by (120 points)

Hello All,

I'm new to Twine so it might be very obvious but can't make it work.

In the previous passage I define variable $gender by typing it in (textbox) I press enter and it should lead me to one of the rooms. However, if I type "female" seems that twine just ignores it and jumps straight to else statement leading me to 'Male bathroom'.

<<if $gender is "female">>
<<goto [[Female bathroom]]>>
<<goto [[Male bathroom]]>>

Any help will be appreciated!

1 Answer

0 votes
by (8.9k points)

That code works so long as $gender is set to "female" and not (say) "Female".  If I were you I'd avoid using a textbox to enter a variable like this.

by (159k points)
There are a number of issues that you need to overcome when asking the Reader to enter a value in a Text-Box.

1. The Reader may not enter a value, so you will need to check for that.

2. The Reader may enter an invalid value, so you will need to check for that.
eg. you wanted "male" or "female" and they entered "1234"

3. The Reader may enter a value using mixed letter case, so you will need to check for that.

For these reasons it is generally a good idea to use links (or some sort of list based input type) when asking a Reader to select one option from a fixed set of possible choices.