Howdy, Stranger!

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

Stupid problem with "is not"?

Hey community, I've been wracking my brain over this stupid problem for ages now and I think it's time to ask for help.

I'm at the end of my project and I'm trying to check that a series of variables are defined, my current code is as follows:
<<if $v1 is not 0 and $v2 is not 0...>>
etc

The "is not" operators don't seem to be working together, this simple test isn't working either:
<<set $test1 to 4>>
<<set $test2 to "hello">>

<<if $test1 is not 0 and $test2 is not 0>>This should work!<<endif>>
Can someone tell me where I'm going wrong? This is driving me up the wall!

Thank you.

Comments

  • (Always state which story format you are using.  They differ, so knowing which you're using matters.)

    The vanilla story formats do not have an is not/isnot operator, so what you're doing there is conjoining the separate is and not operators, which does not work like you're expecting it should (i.e. instead of testing $v1 for inequality to 0, you're actually testing $v1 for equality to the inverse coerced boolean value of 0).

    Of the story formats available for Twine 1, I believe only SugarCube has an actual isnot operator (though is not is also accepted for this very reason, it seems reasonable to combine is and not).

    Anyway, you'll need to use the neq operator.  Like so:

    <<if $v1 neq 0 and $v2 neq 0...>>
  • Thank you very much, I forgot to mention that I am using the Sugarcane format. I don't think I'd seen neq mentioned in any of the resources.

    It's all working now, thank you again.
  • GeneralBison wrote:

    I don't think I'd seen neq mentioned in any of the resources.


    It's under expression (section: Logical operators) in the wiki.
  • TheMadExile wrote:

    GeneralBison wrote:

    I don't think I'd seen neq mentioned in any of the resources.


    It's under expression (section: Logical operators) in the wiki.


    Oh wow, I don't know how I missed that. Sorry.
Sign In or Register to comment.