GlovePIE:Mode Switch Script

From WiiLi

Jump to: navigation, search

Switch between multiple modes or scripts contained in a single script.

//Hold down Wiimote.Home for 1 second to activate script/mode switch mode
//Use the Plus and minus to scroll through the scripts/modes
//Press Wiimote.Home again to select the current script

if !var.Initialize
   var.TotalScripts = 4
   var.CurrentScript = 1
   var.Initialize = true
endif

//Activates script switch mode
if Pressed(HeldDown(Wiimote.Home, 1s))
   var.SwitchScript = true
endif

if var.SwitchScript
   //Sets Wiimote LEDs
   Wiimote.Leds = 2**(var.CurrentScript-1)
   
   //Wiimote.Plus and Wiimote.Minus cycles through modes
   if Pressed(Wiimote.Plus)
      if var.CurrentScript >= var.TotalScripts
         var.CurrentScript = 1
      else
         var.CurrentScript++
      endif
   elseif Pressed(Wiimote.Minus)
      if var.CurrentScript <= 1
         var.CurrentScript = var.TotalScripts
      else
         var.CurrentScript--
      endif
   endif
   
   //Wiimote.Home selects
   if Pressed(Wiimote.Home)
      Wiimote.Leds = 0
      var.SwitchScript = false
   endif
else
   if var.CurrentScript = 1
   //Script/Mode 1 here
   elseif var.CurrentScript = 2
   //Script/Mode 2 here
   elseif var.CurrentScript = 3
   //Script/Mode 3 here
   elseif var.CurrentScript = 4
   //Script/Mode 4 here
   endif
endif

debug = var.SwitchScript + " " + var.CurrentScript
Personal tools
Online Casino - best online casino reviews.
Facebook Developers - facebook applications, facebook developers, facebook development, social network application development and viral widget social media strategy