29 lines
558 B
Lua
29 lines
558 B
Lua
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 |