XML: Increment Variable w/Modulo Reset

From FSDeveloper Wiki
Revision as of 18:01, 28 June 2012 by N4gix (talk | contribs) (New page: ==XML: Increment Variable w/Modulo Reset== {{Infobox-Applicable-FSVersion | FSXA = true | FSX = true | FS2004 = true | FS2002 = false | XP10 = false | XP9 = false }} The following scri...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 upper limit, at which point the variable will reset back to zero!

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>