Hi Twine lovers!
I am struggling at coding a very simple function with Harlowe.
I want item3 to be created once item1 && item2 are clicked.
Here's my code (not sure about the brackets in my first If statement, but doesn't work witout them either) :
[item1]<item1|
[item2]<item2|
(click: ?item1)[(set: $item1_click to true)]
(click: ?item2)[(set: $item2_click to true)]
(if: ($item1_click is true) and ($item2_click is true))[(set:$item3 to true)]
(if: $item3 is true)[item3]
Comments
Where are the item links? In an inventory passage? Are you going to have a lot of crafting and recipes?
By default once a passage is displayed any conditional macros are not re-evaluated even if the variables they are based on are changed. So changing the value of $item1_click to true does not cause the (if: ($item1_click is true) and ($item2_click is true)) line to be re-evaluated.
One way to solve this problem is to re-display the item list each time either item1 or item2 is clicked, thus the conditional line with be re-evaluated.
You should always give your variables a default value before you use them within your code, and Harlow's overview explains how to do this using a passage with a tag of startup.
a. Assigning default values to your variables: Create a new passage (I named mine Startup), assign it a startup tag and copy the following into it: b. Display your list: Add the following to the passage you want the item list to appear in: c. Logic to display the items: Create a new passage named items logic and add the following to it:
Now if you click on both item1 and item2 then item3 will appear.
I didn't now about the Startup/Footer/Header tags, it is so useful, especially for games!