From f66d138c129a0c34011c5173dbfdcb017f914807 Mon Sep 17 00:00:00 2001 From: Laurie Fisher Date: Fri, 27 Jun 2025 14:25:46 +0100 Subject: [PATCH] test --- logger.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 logger.lua diff --git a/logger.lua b/logger.lua new file mode 100644 index 0000000..a232273 --- /dev/null +++ b/logger.lua @@ -0,0 +1,29 @@ +local M = {} + +local logLines = {} +local maxLines = 5 + +function M.log(msg) + local time = textutils.formatTime(os.time(), true) + local entry = string.format("[%s] %s", time, msg) + + table.insert(logLines, entry) + if #logLines > maxLines then + table.remove(logLines, 1) + end + + M.draw() +end + +function M.draw() + local w, h = term.getSize() + for i = 1, maxLines do + term.setCursorPos(1, h - maxLines + i) + term.clearLine() + if logLines[i] then + term.write(logLines[i]) + end + end +end + +return M \ No newline at end of file