Twine Version: 2.3.9
Story Format: SugarCube 2.31.1
I’m using code to create a “correct answer” in a textbox. The game will only let you progress if you’ve inputted the right text. This is what I’m using:
Answer: <<textbox "$code" "" autofocus>> <span id="textbox-error" style="color: red"></span> <<button "Confirm">> <<set $code to $code.trim()>> <<if $code is "name">> <!--This line here is the source of my trouble--> <<goto "Passage 2">> <<else>> <<replace "#textbox-error">>Incorrect Answer<</replace>> <</if>> <</button>>
However, I am trying to make my answers slightly variable. I have code elsewhere that sets the variable $name to a random selection of first and last names. (Like Steven Harris or Walter Green) I want the correct answer in the textbox to change depending on what the name is. I have tried many different things to get this to work:
<<if $code is $name>> <<if $code is "$name">> <<if $code eq "$name">> <<if $code == $name>>
And so on. Everything I’ve tried brings up an error message, has no correct answer, has no wrong answer, or the correct answer is $name. I feel like this code should’ve worked at some point, but I’m at a loss.
Thanks in advance.