Hi. I'm working in Twine 2 in Harlowe. I'm struggling with this If loop. It's basically " If this variable is >0 show some text and a link, otherwise show two links"
(if: $splints >0)[Fortunately you have brought spare shin splints.
Continue -> Challenge 4: Anna arrives
]
(else:)[
(link:"Go to the other team and ask for spares")[(set $score to $score +1)(goto:"3a")]
(link:"Tell Rashida to go over to the other team and ask for spares")[(goto:"3b")]
]
If I set $splints to 1, the first part displays and the link works. But with $splints as 0 the second part displays but the links give an error message "(set 0 to 0 +1)I can't (go-to:) the passage '3a' because it doesn't exist."
3a and 3b do exist, of course.
Could someone please advise me on the right syntax?
Comments
You should never put spaces around the text and link components of a link. For example: Which should actually be: The reason you shouldn't do that is because Twine 2's passage auto-creation code will create the passage with the name " Challenge 4: Anna arrives"—note how it starts with a space, which you likely did not intend.
If you're certain that the "3a" and "3b" passages exist, then ensure that they don't actually start with a space, because that will cause (goto: "3a") to fail as "3a" and " 3a" are different things.
Editing the passage and correcting its name should automatically correct all associated double square-bracketed links for you, so you shouldn't have to worry about doing that manually.
PS: Your (set:) is missing its colon. In other words, this: Should instead be: Or better:
Much appreciated!