Howdy, Stranger!

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

&& & || if statements.

sugarcube 2.17
I've notice that when I and(&&) or or(||) if statements together to make it into one if there is even a simple add or subtraction in the statements they get skipped, or not evaluated. Like
<<if (sim1.age - sim.age2 > 10) && (sim1.relationship >= 4)>> will allow the first test to pass every time, but if left as a single test if it works as it should. Is this a bug?


  • I'm not sure how big of a deal it is since I'm not at my computer right now to test it, but your parentheses are in weird places. Also, sugarcube has its own 'and' and 'or' keywords that you can use.
    <<if $whatever is 1 and $thing >=

    Anyway, why are you not using Twine script variables? Are the variables you're using scoped right?
  • edited April 2017
    Yeah the vars are scoped right as far as I can tell. Not twine vars? they used sugarcubes set to initialize them, Oh you mean my typo of the missing $ or _ sorry. Yes I know about using the and, or, eq, etc. I use the JavaScript way as then sugarcube has a bit less work to do when converting to JavaScript, Anyway I did get it figured out. Thanks.
    Though as to why it didn't work the first few times I don't know. but I used eval on the statement and it worked fine, then I took eval off and it continued to work.
  • Please use the code tag—it's C on the editor bar—when posting code or markup.

    Aside from the missing story/temporary sigils, there's nothing syntactically wrong with the shown code. In which case, I'd suspect either an initial mistype/misspelling which you've since corrected, and simply missed having done so, or data type shenanigans.

    Also, I don't know how fat fingered you normally are, however, since you're using JavaScript's logical AND/OR operators, I'd pay special attention to ensuring you type && and ||, rather than accidentally typing the bitwise operators & and |.
Sign In or Register to comment.