Global Variable numeric wrap around not working

I have a global variable with a range from 0-359, I increment by 6 or subtract by 6 as a unit turns since it is turning 6 degrees. Once the number reaches 360 it does not roll over to 0 again for some reason.


I display the value in chat and it does not wrap around!

I also have the wrap flag checked on the Global Key Command in the unit trait

I forgot to say I am running the latest release 3.5.8

Wouldn’t using “Increment numeric value” (with +6 or -6 as needed) be easier?

Except I need to reference that value when other units are active so I am creating global variables for each unit.

From the reference manual:

If true, then when incrementing this numeric property, values will wrap around from the maximum to the minimum and vice versa.

So you need to use Increment as Joel suggested, not Set Value Directly

1 Like

If for some reason you’re set on using Set Value Directly, then you can take the modulus of 360 (add % 360 to the end of your calculation). For the subtraction command, you would need to add 360 first, then take the modulus (it won’t work correctly on a negative number). Keep in mind that % has higher priority than +, so you’ll also need parentheses for the latter.

Yep that was it, sorry!