I'm a new user, and though I've done some coding with Java and Python before, I'd still consider myself a novice. I'm having trouble with really basic if-else syntax in Harlowe, and this example is pretty close to my issue.
Example:
(if: $animal is "dog") (set: $legAmount to 4)
(if: $animal is "fish") (set: $legAmount to 0)
The $animal has $legAmount legs.
Regardless of whether or not I've set the $animal variable to "dog" or "fish", countless indentation variances and Boolean conditions later I can't seem to get the correct condition. It always sets $legAmount to the most recent number (in this case, 0).
The $animal variable is a string so I can easily display its contents, but I'm by no means married to this type of syntax. I'm sure there's a much easier and more efficient way to implement if: and set: conditions. Much help and patience would be appreciated.
Comments
I probably should have made it more clear, but I would ideally like $animal to be chosen by the player in a previous passage.
Hey, eddies13's code should work. If you can see the brackets when you test the story then they're not being rendered as "code" but as "text". The syntax should make the "]" bold when is interpreted as code.
If you still can't get it to work just paste your code and let's have a look at it
1. Missing colon after the macro name:
In the following two examples the first one will work while the second one wont because the colon after the set macro name is missing.
2. Inserting Space characters in invalid places:
Inserting Space characters between the end of the macro (the close parenthesis ')' character) and it's hook/container (the open square bracket '[' character) will make your code invalid.
Again the first example is correct while the second is invalid because of the extra Space character: