Hey everyone! ^_^
If I wanted the player to be able to textinput, press enter, and then have whatever they typed become the value for a variable, what would I do? I've seen the versions that store a name, and I've seen the one with the button which takes you to a certain passage, but I'm not sure if they're exactly what I need.
Rather, I would like for the text entered to become a value I could then use in an if/elseif situation which displayed different text or images.
For example, (partially in words, haha, because I'm new at code)
Where would you like to go?: forest
If $whatevertheplayertyped = forest display xyz
Else if whatevertheplayertyped = castle display abc
Thank you!
Comments
Well, I've had this problem for a while but a quick Google search got me with this.
<<textinput $variable passage to visit on button click button name>>
For me, I made it so that players can name their own character by putting down the following...
<<textinput $name PASSAGETITLE Enter>>
So whenever I type <<print $name>>, their chosen name shows up! But for Sugarcube, apparently it's a bit different.
I hope I helped a little.
But I would like a way to store a variable without a button at all? Rather, with a keyboard press of 'Enter'.
And I would like the identity of that variable to be what takes the player to different passages.
For example, if they typed "Moon", they would be taken to the passage called "Moon"
Is that possible?
That's some high-tech shit right there - I may be an amateur who is still new at this but I don't see how this would work without using some serious coding. I'd suggest sticking to the basics, as utilizing the use of variables alone would get you to high places. xD
I explicitly removed the "Enter key" functionality from <<textinput>> in transporting it from 1.3.6 to 1.4.1, because I felt it wasn't in keeping with a general rule of the Twine game interface: navigation = clicking. That, and I couldn't figure out what should intuitively happen when multiple <<textinput>> regions were present in the passage.
As for the second request... try this:
<<textinput $input "Text" "Next passage">>
and, in the "Next passage" passage,
<<display $input>>.
Of course this has some of <<display>>'s limitations - it doesn't count as being visited(), and doesn't inherit the tags.