Posted 03 July 2013 - 04:01 PM
Hi guys,
I'm currently writing on a server-system and I need an function like os.pullEvent() with a Timeout.
This is nearly working, but it breaks the loop after 1 to 3 seconds:
Anyone know, how to fix it, or an alternative possibility to make an os.pullEvent with timeout?
mark332
PS: Sry, if my english is bad :)/> I'm german.
I'm currently writing on a server-system and I need an function like os.pullEvent() with a Timeout.
This is nearly working, but it breaks the loop after 1 to 3 seconds:
-- Notice: This is placed in my own API named "gen" so I can call it with gen.pullEvent()
function pullEvent(ExTimeOut, ExEvent)
local ExTimeOut = 3
if ExTimeOut > 1 then
timer = os.startTimer(ExTimeOut)
while true do
event = {os.pullEvent()}
if event then
if event[1] == ExEvent then
break
end
else
break
end
if event[1] == "timer" and event[2] == timer then
event[3] = "timeout!"
break
end
end
return event
end
end
Anyone know, how to fix it, or an alternative possibility to make an os.pullEvent with timeout?
mark332
PS: Sry, if my english is bad :)/> I'm german.