v0.3.1 - Fixed the infamous bug
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).
This commit is contained in:
+10
-11
@@ -2,19 +2,17 @@ local event = {}
|
||||
|
||||
local ocelot = component.proxy(component.list("ocelot")())
|
||||
|
||||
function event.pull(type, timeout)
|
||||
checkArg(1, type, "string", "nil")
|
||||
function event.pull(evtype, timeout)
|
||||
checkArg(1, evtype, "string", "nil")
|
||||
checkArg(2, timeout, "number", "nil")
|
||||
local startTime = computer.uptime()
|
||||
local args
|
||||
repeat
|
||||
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]))
|
||||
ocelot.log(tostring(evmgr.eventQueue[i][3]))
|
||||
ocelot.log(tostring(evmgr.eventQueue[i][4]))
|
||||
if evmgr.eventQueue[i][1] >= startTime and (evmgr.eventQueue[i][2] == type or not type) then
|
||||
ocelot.log(tostring(evmgr.eventQueue[i][1]).." ("..type(evmgr.eventQueue[i][1]).."), "..tostring(evmgr.eventQueue[i][2]))
|
||||
--ocelot.log(tostring(evmgr.eventQueue[i][3]))
|
||||
--ocelot.log(tostring(evmgr.eventQueue[i][4]))
|
||||
if evmgr.eventQueue[i][1] >= startTime and (evmgr.eventQueue[i][2] == evtype or not evtype) then
|
||||
args = evmgr.eventQueue[i]
|
||||
break
|
||||
end
|
||||
@@ -24,9 +22,10 @@ function event.pull(type, timeout)
|
||||
end
|
||||
until args and not timeout or args and timeout and (args or computer.uptime() >= startTime + timeout)
|
||||
if args then
|
||||
table.remove(args, 1)
|
||||
return table.unpack(args)
|
||||
--[[ table.remove(args, 1)
|
||||
return table.unpack(args) ]]
|
||||
return args[2]
|
||||
end
|
||||
end
|
||||
|
||||
return event
|
||||
return event
|
||||
|
||||
Reference in New Issue
Block a user