mirror of
https://github.com/Kiritow/OpenComputerScripts.git
synced 2024-03-22 13:10:46 +08:00
Update libevent
Fix WaitMultipleEvent Check Times before adding timer.
This commit is contained in:
parent
9c4081a0df
commit
9d4dd91328
15
libevent.lua
15
libevent.lua
|
@ -287,13 +287,9 @@ function WaitEvent(...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Usage: WaitMultipleEvent([timeout],Event1,Event2,...)
|
||||||
function WaitMultipleEvent(...)
|
function WaitMultipleEvent(...)
|
||||||
local tb=table.pack(...)
|
-- event.pullMultiple will check the param
|
||||||
for i=1,tb.n,1 do
|
|
||||||
if(type(tb[i])~="string") then
|
|
||||||
error("Syntax error. Usage: WaitMultipleEvent(EventName1,[EventName2]...)")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return TranslateEvent(table.pack(event.pullMultiple(...)))
|
return TranslateEvent(table.pack(event.pullMultiple(...)))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -306,9 +302,12 @@ function AddTimer(Interval,CallbackFunction,Times)
|
||||||
checknumber(Interval)
|
checknumber(Interval)
|
||||||
checkfunction(CallbackFunction)
|
checkfunction(CallbackFunction)
|
||||||
checknumber(Times)
|
checknumber(Times)
|
||||||
if(Times<1) then -- Timer will infinitly run (when times <0)
|
|
||||||
|
-- If times==0, just don't add it.
|
||||||
|
|
||||||
|
if(Times<0) then -- Timer will infinitly run (when times <0)
|
||||||
return event.timer(Interval,CallbackFunction,math.huge)
|
return event.timer(Interval,CallbackFunction,math.huge)
|
||||||
else -- Timer will run [Times] times.
|
elseif(Times>0) then -- Timer will run [Times] times.
|
||||||
return event.timer(Interval,CallbackFunction,Times)
|
return event.timer(Interval,CallbackFunction,Times)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user