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).
63 lines
1.4 KiB
Lua
63 lines
1.4 KiB
Lua
_G.cormgr = {}
|
|
_G.cormgr.corList = {}
|
|
|
|
--local ocelot = component.proxy(component.list("ocelot")())
|
|
|
|
local filesystem = import("filesystem")
|
|
|
|
function _G.cormgr.loadCoroutine(path)
|
|
local cor = coroutine.create(function()
|
|
import(path)
|
|
end)
|
|
table.insert(_G.cormgr.corList, cor)
|
|
end
|
|
|
|
function handleError(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()
|
|
for i = 1, #_G.cormgr.corList do
|
|
local result, errorMessage = coroutine.resume(_G.cormgr.corList[i])
|
|
if not result then
|
|
handleError(errorMessage)
|
|
end
|
|
if coroutine.status(_G.cormgr.corList[i]) == "dead" then
|
|
table.remove(_G.cormgr.corList, i)
|
|
break
|
|
end
|
|
--computer.pullSignal(0)
|
|
--coroutine.yield()
|
|
end
|
|
end
|
|
|
|
local handle = filesystem.open("/halyde/config/startupapps.txt", "r")
|
|
local data = ""
|
|
local tmpdata
|
|
repeat
|
|
tmpdata = handle:read(math.huge or math.maxinteger)
|
|
data = data .. (tmpdata or "")
|
|
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")
|
|
|
|
while true do
|
|
runCoroutines()
|
|
if #_G.cormgr.corList == 0 then
|
|
computer.shutdown()
|
|
end
|
|
end
|