It looks like you're new here. If you want to get involved, click one of these buttons!
|TheGun>[(link: "Take the gun")[(set: $Gun to 1)(replace: ?TheGun)[You take the gun and put it in the pocket of your jacket.]] or (link: "refuse it")[(replace: ?TheGun)[You refuse to take the gun and hand it back.]]]
Comments
note: it is a good idea to initialize all your $variables at the start of your story before you use then, don't rely on the story format automatically doing it for you.
So if I take your example and add a markup link to a new passage named Next: ... and within the new Next passage I add the following test: .. and then test the above by either clicking on your "Take the gun" before clicking on the "Next" link, or clicking on your "refuse it" link before clicking on the "Next" link, I get the following two results.
thanks for your thoughts.
The reason I thought the $Gun variable wasn't being set is that when I put some test code similar to yours just after the code to link and replace, it still showed 0 whatever choice was clicked. Sure enough when I test it in a different passage it gives the expected answer.
Perhaps it's just me, but that feels rather counter-intuitive. My expectation is that because the (replace:) has generated an immediate result in the current passage, the (set:) should do so as well. Not sure if this is a 'feature' in harlowe (i.e. there is a good reason for it), or a bug.
cheers
GDL
(Of course, there's a strong case for having special passage structures that constantly mirror values of variables, and in the future I may implement those. For now, though, you'll have to stick with judicious use of the (live:) macro.)
Thanks greyelf - that works great.
Cheers
GDL