mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-22 12:04:20 -05:00
made event.lua work with the new restrictions on the scheduler and such
This commit is contained in:
parent
37df78ffed
commit
180a5a9a78
@ -23,16 +23,13 @@ function event.pull(t,...) -- return an event, optionally with timeout *t* and f
|
|||||||
end
|
end
|
||||||
|
|
||||||
function event.listen(e,f) -- run function *f* for every occurance of event *e*
|
function event.listen(e,f) -- run function *f* for every occurance of event *e*
|
||||||
local op = os.getenv("parent")
|
|
||||||
os.setenv("parent",cPid)
|
|
||||||
os.spawn(function() while true do
|
os.spawn(function() while true do
|
||||||
local tEv = {coroutine.yield()}
|
local tEv = {coroutine.yield()}
|
||||||
if tEv[1] == e then
|
if tEv[1] == e then
|
||||||
f(table.unpack(tEv))
|
f(table.unpack(tEv))
|
||||||
end
|
end
|
||||||
if not tTasks[os.getenv("parent")] or (tEv[1] == "unlisten" and tEv[2] == e and tEv[3] == tostring(f)) then break end
|
if not os.taskInfo(os.taskInfo().parent) or (tEv[1] == "unlisten" and tEv[2] == e and tEv[3] == tostring(f)) then break end
|
||||||
end end,string.format("[%d] %s listener",cPid,e))
|
end end,string.format("[%d] %s listener",os.pid(),e))
|
||||||
os.setenv("parent",op)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function event.ignore(e,f) -- stop function *f* running for every occurance of event *e*
|
function event.ignore(e,f) -- stop function *f* running for every occurance of event *e*
|
||||||
|
Loading…
Reference in New Issue
Block a user