GlovePIE:One Button Two Functions
From WiiLi
The following script shows how to respond differently to when a button has either been pressed or held.
A generic solution to the problem is as follows:
if Released(<condition>)
if !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
The following is an example using the Wiimote.A button being held or pressed. When held the Down key is pressed, when pressed the up key is pressed.
if !var.init
var.HeldTime = 400ms
var.init = true
endif
if Released(Wiimote.A)
if !var.Held
Press(Up)
wait 25ms
Release(Up)
else
var.Held = false
endif
else
if Pressed(HeldDown(Wiimote.A, var.HeldTime))
Press(Down)
wait 25ms
Release(Down)
var.Held = true
endif
endif
If you require the helddown condition to respond to another button being held and not just pressed remove the pressed() function.

