From 56946ee55e1a9c7127134534190d50241850e3ef Mon Sep 17 00:00:00 2001 From: hkc Date: Thu, 12 Oct 2023 20:42:25 +0300 Subject: [PATCH] Verbose logging --- augment/main.lua | 25 +++++++++---------------- augment/modules/wh.lua | 2 +- augment/startup.lua | 6 +++++- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/augment/main.lua b/augment/main.lua index eec6fe3..f52f2f8 100644 --- a/augment/main.lua +++ b/augment/main.lua @@ -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!") diff --git a/augment/modules/wh.lua b/augment/modules/wh.lua index e5817cf..5d3f909 100644 --- a/augment/modules/wh.lua +++ b/augment/modules/wh.lua @@ -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) diff --git a/augment/startup.lua b/augment/startup.lua index 5107384..2accb1d 100644 --- a/augment/startup.lua +++ b/augment/startup.lua @@ -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")