Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Issue with Nested Brackets? (2.0.8, Harlowe)

So, I've run into a weird issue with nested square brackets. I have a snippet of code like this:
(elseif: $Acre1A is 1)[\
(if: ($money >= 100)) and ($Crop1Unlock is false))[\
(set: $Crop1Unlock to true)\
Now avaliable: grin emojis!<br>]\
(if: ($money >= 300) and ($Crop2Unlock is false))[\
(set: $Crop2Unlock to true)\
Now avaliable: kiss emojis!<br>]\
(if: ($money >= 500) and ($Crop3Unlock is false))[\
(set: $Crop3Unlock to true)\
Now avaliable: sunglasses emojis!<br>]\
<!-- etc. etc. -->
]\
And, as far as I can tell, that ought to work pretty well, however, Twine seems to think that the bracket at the end of line 4 closes the else-if rather than the open bracket at the end of line two. Because of this, whenever I run this page, all the other ifs end up getting run, regardless of if $Acre1A is 1 or not. Is there a way to trick it into understand which pairs of brackets pair up? Am I making a giant mistake somewhere?

Attached is a screencap of the way the code currently looks in Twine; as you can see, the highlight stops at the wrong bracket, opening the subsequent ifs up to run unchecked.

Comments

  • The second line of your example has an extra close bracket after the >= 100 which is causing the second conditional of the (if:) macro to be invalid, which in turn is invalidating the open square bracket that follows that (if:) macro.
    eg.
    (if: ($money >= 100)) and ($Crop1Unlock is false))[\
    
    ... should be:
    (if: ($money >= 100) and ($Crop1Unlock is false))[\
    
Sign In or Register to comment.