Howdy, Stranger!

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

using < > symbols with If statements using variable In Harlowe 2.1.1

Ive been having some trouble. I don't know if twine just doesnt support what im trying to do or if there is another way to go about it. basically when a variable reaches a certain point i want something to happen. however since it deals with negatives and positives and the exact number they could have can change I can simply say
(if: $var is -1)[ blah blah blah]
Here's what ive been doing and there is not error message it just doesn't do what is after the if statement even when it is a negative.
first passage is this.
(link: "test")[(set: $affection to -1)(goto: "test2")]
this is on the second passage test2
(if: $affection is < 0)[ You are dead.]
(print: $affection)
When it prints the variable it is indeed -1 however it does not show the you are dead text. any help would be appreciated.

Comments

  • edited April 2017
    Later versions of Harlowe support combining "is" with < or > etc, but it's not a great practice, and I'd recommend getting rid of it.

    I don't see anything else wrong off hand, but my brain's a bit cooked right now. Twine absolutely has the ability to compare negatives, since its mostly JavaScript with a bunch of syntactic sugar on top.

    Edit.

    I don't know that there is a harlowe 2.1.1. Are you sure you aren't using twine 2.1.1 and harlowe 1.x? I think the feature I described above that allows "is" and other operators to be used together is a harlowe 2.x thing. In other words, your problem is probably that you need to delete the "is" from your (if:) macro.
  • I'm pretty sure you have to do this:
    (if: $affection is <= -1)[ You are dead.]
    (print: $affection)

    So it says if it's smaller or equal to -1. That's what I always do.
  • edited April 2017
    @Chapel You are right. I had it on Harlowe 1 instead of 2. Not sure how that happened but that explains a lot. using both or your suggestions it finally works. I didn't think to check what version i was using. sorry bout that. also Im trying to show that its been answered and not having very much luck? first post so kinda new to this part of it.
  • edited April 2017
    Deadshot wrote: »
    I'm pretty sure you have to do this:
    (if: $affection is <= -1)[ You are dead.]
    (print: $affection)

    So it says if it's smaller or equal to -1. That's what I always do.

    As I said in my previous comment, "is" really, really, really shouldn't be used with other operators, because it is a TwineScript operator already (for "==="). Harlowe 2.x allows it, but it isn't a good habit to be in, and it's still an error--you're counting on Harlowe to fix the error for you.

    Also, x <= -1 and x < 0 are functionally the same. There are some reasons to occasionally choose one over the other, but either one should work.
    [...] Im trying to show that its been answered and not having very much luck? first post so kinda new to this part of it.

    I think you started this topic as a discussion rather than a question. Not a big deal, happens all the time. If it were a question, you'd see an option to "accept this answer" at the bottom of every comment.
  • Chapel wrote: »
    Deadshot wrote: »
    I'm pretty sure you have to do this:
    (if: $affection is <= -1)[ You are dead.]
    (print: $affection)

    So it says if it's smaller or equal to -1. That's what I always do.

    As I said in my previous comment, "is" really, really, really shouldn't be used with other operators, because it is a TwineScript operator already (for "==="). Harlowe 2.x allows it, but it isn't a good habit to be in, and it's still an error--you're counting on Harlowe to fix the error for you.

    Also, x <= -1 and x < 0 are functionally the same. There are some reasons to occasionally choose one over the other, but either one should work.
    [...] Im trying to show that its been answered and not having very much luck? first post so kinda new to this part of it.

    I think you started this topic as a discussion rather than a question. Not a big deal, happens all the time. If it were a question, you'd see an option to "accept this answer" at the bottom of every comment.

    I know that x <= -1 and x < 0 are the same, but the first one always works with me. And, sorry, I forgot to take the "is" out.
    (if: $affection <= -1)[ You are dead.]
    (print: $affection)

    That's what I do.
  • Thank you very much. Its coming along swimmingly since then.
Sign In or Register to comment.