How to: If X + Y / 2 is between a certain range?

How was that done again?
I think there was a way to have the game check if the result of two variable was within a certain range.

was it

*if ((x + y /2) >= z))

?
So, e.g.

*if ((x + y /2) >= 60))
   *goto success
*else
   *goto fail

?

1 Like

I believe you need double brackets. So:

*if (((x+y) /2) >= 60)
   *goto success
4 Likes

couple things:

  • you’ll want to throw in a paren after y, eg (((x+y)/2)>z) otherwise it’ll throw a fit trying to parse it (at least CSIDE will)–error is something like expected CLOSE_PARENTHESIS was: OPERATOR /

  • I’m sure someone who can actually code will have a better answer, but i’d just do it with a temp

*temp foo (x+y)
*if ((foo / 2) > z)
    *goto success
*else
    *goto fail

But yeah, if you add the extra paren it’ll execute as you expect, so just a style choice, depends if you want to save that temporary value to check it against anything later

3 Likes

I’ll do a testrun later on, thank you