Page 1 of 1

Wait ... if no keystroke within 10 minutes then logout

Posted: Sun Oct 14, 2012 12:15 am
by Edamh
Any ideas how to code the following pseudocode?

Code: Select all

Arrive at location
Wait/sleep 10 minutes
if keystroke within 10 minutes
then
   continue to point B
else
   logout (that is, no keystroke in 10 minutes)
end if
I don't know how to sleep AND check for keystroke during the 10 minutes. Tips and pointers appreciated. Thanks.

Re: Wait ... if no keystroke within 10 minutes then logout

Posted: Sun Oct 14, 2012 12:38 am
by rock5
Maybe

Code: Select all

local starttime = os.clock()
repeat
    yrest(50)
    if os.clock() - starttime > 600 then
        player:logout()
    end
until keyPressed(key.VK_SPACE)
I don't think there is a way to say if any key is pressed. I think it has to be a specific key. I used space bar in the code above.

Re: Wait ... if no keystroke within 10 minutes then logout

Posted: Mon Oct 15, 2012 9:17 am
by Edamh
Works great. Thank you!