Thought I'd share a hacky way to emulate "choice" in twine 2 & Harlowe.
The game I'm working on is in the format of a diary, with the player making choices in the page, which reveal the result of the choice, hides the other not-chosen choices, and reveals a link to continue to the next diary page. So I'm breaking with the "every passage is a new page" paradigm...
Major caveats with this code are;
a) it reloads the current page
b) be careful or you'll throw an infinite loop which will lock up a browser
c) after digging into Harlowe a bit more there look to be more elegant ways of doing this (but they are all hacky)
Blah blah blah blah blah blah blah.
(if: $chosen is 0)[ \
Choose an option:
(set: $opt1 = "I got 80% in computing")
1. (link: $opt1)[ (set: $com += 1) (set: $chosen = $opt1) (goto: "diary11")
] \
(set: $opt2 = "I got 73% in Physical Sports")
2. (link: $opt2)[ (set: $phy += 1) (set: $chosen = $opt2) (goto: "diary11")
] \
(set: $opt3 = "I got 88% in Science")
3. (link: $opt3)[ (set: $sci += 1) (set: $chosen = $opt3) (goto: "diary11")
] \
(set: $opt4 = "I failed everything but who cares")
3. (link: $opt4)[ (set: $cha += 1) (set: $chosen = $opt4) (goto: "diary11")
] \
] \
(else:)[
**$chosen**
(if: $chosen is $opt1)[(set: $chosen = 0)Mr Smith said i could be an Programmer when i grow up.]
(if: $chosen is $opt2)[(set: $chosen = 0)Mr Smith said i should keep practicing and i will grow up strong.]
(if: $chosen is $opt3)[(set: $chosen = 0)Mr Smith said i got a very good score, and maybe one day I could be a Chemist]
(if: $chosen is $opt4)[(set: $chosen = 0)Dad was gonna be angry so went home late.]
[[Continue|diary12]]
]
Note all the
goto: "diary11" --
"diary11" should be changed to the name of your current passage. In the Continue link is, of course, the name of the next passage. $opt1-4 are the descriptions of the options the player can choose from.
In these choices, the player is a child picking their exam result and getting an appropriate message displayed. The variables $com $sci $phy and $cha are arbitrary variables I use elsewhere and not related to this solution (they are skills improved by the player's choice), but show you how to set unrelated variables as a result of the choice.
Not the most elegant solution but maybe ppl will find it useful.
Comments
Harlowe includes the (passage:) macro which can be used to obtain the current passage's name.
A slightly modified version of your example, note the inclusion of the $here variable and it's usage in the (goto:) macros.