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:
@@ -28,4 +28,4 @@ end
|
||||
--assert(handle:write("Bazinga!"))
|
||||
--handle:close()
|
||||
|
||||
import("/halyde/core/cormgr.lua")
|
||||
import("/halyde/core/cormgr.lua")
|
||||
|
||||
+11
-4
@@ -13,8 +13,12 @@ function _G.cormgr.loadCoroutine(path)
|
||||
end
|
||||
|
||||
function handleError(errormsg)
|
||||
-- nothing for now
|
||||
assert(false, errormsg)
|
||||
if errormsg~=nil then
|
||||
-- nothing for now
|
||||
error(tostring(errormsg))
|
||||
else
|
||||
error("An error has occured, but given as 'nil'.")
|
||||
end
|
||||
end
|
||||
|
||||
local function runCoroutines()
|
||||
@@ -41,15 +45,18 @@ repeat
|
||||
until not tmpdata
|
||||
for line in data:gmatch("([^\n]*)\n?") do
|
||||
if line ~= "" then
|
||||
--[[ if _G.print then
|
||||
print(line)
|
||||
end ]]
|
||||
_G.cormgr.loadCoroutine(line)
|
||||
runCoroutines()
|
||||
end
|
||||
end
|
||||
_G.cormgr.loadCoroutine("/halyde/core/shell.lua")
|
||||
-- _G.cormgr.loadCoroutine("/halyde/core/shell.lua")
|
||||
|
||||
while true do
|
||||
runCoroutines()
|
||||
if #_G.cormgr.corList == 0 then
|
||||
computer.shutdown()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,15 +2,17 @@ _G.evmgr = {}
|
||||
_G.evmgr.eventQueue = {}
|
||||
local maxEventQueueLength = 10 -- increase if events start getting dropped
|
||||
|
||||
--local ocelot = component.proxy(component.list("ocelot")())
|
||||
local ocelot = component.proxy(component.list("ocelot")())
|
||||
|
||||
while true do
|
||||
local args
|
||||
repeat
|
||||
args = computer.pullSignal(0)
|
||||
if args then
|
||||
table.insert(evmgr.eventQueue, table.pack(computer.uptime(), args))
|
||||
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:")
|
||||
@@ -22,4 +24,4 @@ while true do
|
||||
end
|
||||
until not args
|
||||
coroutine.yield()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,6 +6,6 @@ local event = import("event")
|
||||
print("\n │\n │ ".._OSVERSION..'\n │ Welcome! Type "help" to get started.\n │')
|
||||
while true do
|
||||
--coroutine.yield()
|
||||
local args = table.pack(event.pull("key_down"))
|
||||
local args = {event.pull("key_down")}
|
||||
--ocelot.log(tostring(args[1]))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user