Hi,
I'm new to twine but I do a bit of coding and I've used similar programmes before. I've seen that you can use <<textinput>> to allow users to type in some text, and that text will be set to a variable. What I want to do is have the text be conditional, so that users have to input pre-defined 'answers' to move on to the next passage. For example, a passage might read "What is the name of the current Queen of England?" and users would have to input "Elizabeth" or something along those lines to move to the next passage. I realise this would probably mean defining a few correct answers. How would this be done?
Comments
Where "secret" is the password you wish to set
Because you want to save the text entered by the Reader into a variable the following solution which is based on this hack worked out by csalzman.
The following code needs to be placed within your Story Javascript area, it adds a customScripts.updateNamedHook method which can be used with either a Text Field or a Text Area.
The following code needs to be placed within a passage, it asks question and checks the answer. The supplied answer is converted to lower-case before being compared to the correct answer because you cant control the letter casing the Reader may use.