This commit is contained in:
kepler155c@gmail.com
2017-10-08 17:45:01 -04:00
parent 98ec840db1
commit a625b52bad
46 changed files with 334 additions and 319 deletions

View File

@@ -1,3 +1,5 @@
local os = _G.os
local Event = {
uid = 1, -- unique id for handlers
routines = { }, -- coroutines
@@ -123,13 +125,13 @@ function Event.waitForEvent(event, timeout)
local e = { os.pullEvent() }
if e[1] == event then
return table.unpack(e)
end
end
until e[1] == 'timer' and e[2] == timerId
end
function Event.addRoutine(fn)
local r = {
co = coroutine.create(fn),
co = coroutine.create(fn),
uid = nextUID()
}
setmetatable(r, { __index = Routine })