1
0
Fork 0

Verbose logging

This commit is contained in:
Casey 2023-10-12 20:42:25 +03:00
parent 314935401c
commit 56946ee55e
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
3 changed files with 15 additions and 18 deletions

View File

@ -13,17 +13,13 @@ _G.entities = {}
local function run_wrapped(func, filename)
return function()
print("Starting module "..filename)
local ok, res = pcall(func)
local oldc = term.getTextColor()
if ok then
term.setTextColor(colors.blue)
print("module "..filename.." exited")
print("Module "..filename.." exited: " .. tostring(res))
else
term.setTextColor(colors.blue)
print("module "..filename.." crashed: " .. res)
printErr("Module "..filename.." crashed: " .. res)
end
term.setTextColor(oldc)
end
end
@ -58,8 +54,9 @@ local function safeset(func, name, old)
end
print("Running...")
parallel.waitForAll(table.unpack(modules), function()
while true do
parallel.waitForAll(function()
print("Exit handler started")
while _G._running do
local ev = { os.pullEvent("exit") }
if ev[1] == "exit" then
_G._running = false
@ -71,18 +68,14 @@ parallel.waitForAll(table.unpack(modules), function()
end
end
end,
function()
function() -- Neural Interface coroutine
print("NI routine started")
while _G._running do
_G.player = safeset(NI.getMetaOwner, "getMetaOwner()", _G.player)
_G.entities = safeset(NI.sense, "sense()", _G.entities)
os.sleep(0.05)
end
end,
function()
while _G._running do
_G.canvas3d.recenter()
os.sleep(0.05)
end
_G.canvas3d_src.clear()
end)
end, table.unpack(modules))
print("Goodbye!")

View File

@ -4,7 +4,7 @@ return function()
local cubes = {}
while _G._running do
local el = entities
print("found "..#entities.."entities")
print("found "..#entities.." entities")
for i, cube in ipairs(cubes) do
if el[i] == nil then
cube.setSize(0.0, 0.0, 0.0)

View File

@ -15,7 +15,11 @@ local function getFile(url, path)
end
for i, file in ipairs(files.files) do
getFile(files.repository .. "/" .. file.src, file.path)
if type(file) == "string" then
getFile(files.repository .. "/" .. file, file)
else
getFile(files.repository .. "/" .. file.src, file.path)
end
end
shell.run("main.lua")