FSDeveloper Community

Go Back   FSDeveloper Community > FSDeveloper Wiki

XML: Increment Variable w/Modulo Reset

From FSDeveloper Wiki

[edit] 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>

All times are GMT -4. The time now is 05:48.

Kirsch designed by Andrew & Austin


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Powered by vbWiki Pro 1.3 RC4. Copyright ©2006-2007, NuHit, LLC