Howdy, Stranger!

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

[harlowe] multiple conditions in an if macro

edited April 2017 in Help! with 2.0
i'm trying to make a customizable point buy calculator - right now, this is my code:
POWER: $statPWR (if:$statPWR is < 16 and $pointTotal is > 0)[(link-repeat:"[increase]")[(set:$statPWR to it + 1)]] (if:$statPWR > 6)[(link-repeat:"[decrease]")[(set:$statPWR to it - 1)]]

i'm trying to get that if statement to work - for the time being, i'm going to try nesting the if statements, but i'd like a better solution.

edit: i was being dumb, my friend helped me out, it's working now. i don't know how to delete a post, if that's something you can do, but this is resolved.

Comments

  • Next time can you please state the full version number of the story format you are using, as answers can be different for each one.

    I'm glad you found the answer, for anyone else reading this question the issue was that as currently coded the condition of the (if:) macro is only evaluated once at the time the passage was processed and rendered.

    To get that code to work correct it would need to be restructured so that the (if:) was part of the (link-repeat:) macros associated hooks, that way it the condition would be re-evaluated each time the reader selected one of the related links.

    If this was a Question (not a Discussion) then marking this comment as an Answer will cause it to no longer appear in the Unanswered category.
  • edited April 2017
    Beyond what was mentioned by greyelf and for any future readers of the thread.

    In Harlowe v1, the following:
    (if:$statPWR is < 16 and $pointTotal is > 0)
    
    Attempts to combine various conditional operators—specifically, the equality operator is with the relational operators < and >—which is not legal.

    It should have been written like so:
    (if:$statPWR < 16 and $pointTotal > 0)
    


    Harlowe v2 includes workarounds to allow for those combinations, though I would still recommend against doing so, since it's meaningless and will not work just about anywhere else—frankly, a targeted error message would have been better than allowing the combinations, IMO.
Sign In or Register to comment.