For my game, I'm trying to use the button macro in a very specific way. I see there are ways for the player to enter their own information; however, I want the player to enter a code/key word, and send them to a different passage depending on what they typed. So, if they typed "A", they'd to to Passage A, and if they typed "B", they'd go to Passage B. Is there any way to do this?
Comments
This textbox will update the $variable with what the player types, then sends them to passage. Then in passage you would have results for A, B and failure:
If you really, really want to use different passages, you can use a <<goto>> macro in a transitional passage to direct the player based on a variable, eg. in passage referenced above where the player arrives after entering text, instead of any text, you would have:
That way as soon as the passage loads, the player is redirected to a new passage based on the variable set. This gets you the results you are after but it is not as efficient as putting everything in one passage.
1. Remember to assign a default value to your $variable before using it in the <<textbox>> macro, this should be done in your StoryInit passage.
This will stop it showing "undefined" when the textbox is displayed.
2. One issue that can happen whenever you compare user input to a known value is that the user may enter a value using different casing than what you were expecting:
eg. your checking for "Hello" and the user enters "hello"
To get around this issue you should convert whatever the user enters to lowercase before comparing it to a known value:
3. If you do decide to get the user to enter actual passage titles, then remember that passage titles are case sensitive. So you will again need to convert their input to lowercase before using their input within a <<goto>> macro, you will also need to make all the titles of the passages that they can go to lowercase.
eg. The user inputs "The Beach"
They are written using Twee notation, where a line starting with a double colon :: indicates the start of a new passage, and the text following directly after the double colon is the title of the new passage. The text on all the lines below one containing a double is the contents of the new passage until either another double colon is encountered or the example ends.
I got it to work! Thanks again, @greyelf and @Claretta for your help.