XML: Increment Variable w/Modulo Reset
From FSDeveloper Wiki
XML: Increment Variable w/Modulo Reset
The following script shows how to increment the custom (L:Variable,unit) value by 1 on each "click". The number preceeding the modulo operator (%) is the reset point (highcount + 1), at which point the variable will reset back to zero!
NOTE: this technique works for integers only. Fractional increment/decrement should use other methods.
0 + click = 1; 1 mod 5 = 1 1 + click = 2; 2 mod 5 = 2 2 + click = 3; 3 mod 5 = 3 3 + click = 4; 4 mod 5 = 4 4 + click = 5; 5 mod 5 = 0
<MouseRect> <Cursor>Hand</Cursor> <TooltipText>Window Left</TooltipText> <CallbackCode> (L:SwitchWindowLeft, enum) ++ 5 % (>L:SwitchWindowLeft, enum) </CallbackCode> </MouseRect>