Button help

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
jivemasta
Posts: 2
Joined: Wed Aug 24, 2005 2:23 pm

Button help

Post by jivemasta »

Ok, I have the code to see when you press a button. But I only want it to go through the code for the button press once while its held down. now it does it every time it goes through the main loop. Is there a way to tell when its lifted so it will only work when they lift the button?
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Re: Button help

Post by Arwin »

jivemasta wrote:Ok, I have the code to see when you press a button. But I only want it to go through the code for the button press once while its held down. now it does it every time it goes through the main loop. Is there a way to tell when its lifted so it will only work when they lift the button?
You could set a variable when it is pressed, and then keep your loop going while that variable is true, until the

crossdetected = true
ispressed = true
while ispressed
pad.read()
if pad:cross()
crossdetected = true
else
if crossdetected
crossdetected is false
endif
endif
wend

But I think there was another way, something like pad:_cross(), the underscore indicating that there was a release. You should look at the example Shine gave in my thread on button presses, as that one distinguishes between presses and releases.
Post Reply