6f1508d1bf
TheWahlolly didn't know that arrays were stored in pointers when set into another variable, affecting the original array. I also made some changes into the code for ocelot logs so signals are much clearer to investigate (I hope).
28 lines
843 B
Lua
28 lines
843 B
Lua
_G.evmgr = {}
|
|
_G.evmgr.eventQueue = {}
|
|
local maxEventQueueLength = 10 -- increase if events start getting dropped
|
|
|
|
local ocelot = component.proxy(component.list("ocelot")())
|
|
|
|
while true do
|
|
local args
|
|
repeat
|
|
args = computer.pullSignal(0)
|
|
if args then
|
|
ocelot.log("Sending signal "..args..","..computer.uptime())
|
|
table.insert(evmgr.eventQueue, {computer.uptime(),args})
|
|
while #evmgr.eventQueue > maxEventQueueLength do
|
|
ocelot.log("Queue length breach, removing first signal")
|
|
table.remove(evmgr.eventQueue, 1)
|
|
end
|
|
--ocelot.log("Event queue:")
|
|
for i = 1, #evmgr.eventQueue do
|
|
--ocelot.log("Args 1 and 2:")
|
|
--ocelot.log(tostring(evmgr.eventQueue[i][1]))
|
|
--ocelot.log(tostring(evmgr.eventQueue[i][2]))
|
|
end
|
|
end
|
|
until not args
|
|
coroutine.yield()
|
|
end
|