parsed.org

This is a GlovePie example of a button that reacts differently depending on if the user quickly presses the button or holds it down.

The basic structure for this is:

if Released(<condition>)
   if not var.Held
      //Do something in response to pressed condition
   else
      var.Held = false
   endif
else
   if Pressed(HeldDown(<condition>, <time required>))
      //Do something in response to helddown condition
      var.Held = true
   endif
endif

A working example where tapping the A button sends "Up" keystroke and holding it down for 400ms sends "Down":

if not var.init
   var.HeldTime = 400ms
   var.init = true
endif

if Released(Wiimote.A)
   if not var.Held
      Press(Up)
      wait 25ms
      Release(Up)
   else
      var.Held = false
   endif
else
   if HeldDown(Wiimote.A, var.HeldTime)
      Press(Down)
      wait 25ms
      Release(Down)
      var.Held = true
   endif
endif
buttonsglovepiescriptswiiwiimote
RSS