Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --sys2_service_log
- os.loadAPI("sys/syslib")
- --syslib end
- local lines = {}
- local monitor = peripheral.find("monitor")
- local width, height = monitor.getSize()
- local line = 1
- function exLog(group, txt)
- txt = group .. ": " .. txt
- local pts = {}
- while string.len(txt) > width do
- table.insert(pts, string.sub(txt, 1, width))
- txt = string.sub(txt, width + 1, -1)
- end
- table.insert(pts, txt)
- for i, txt in pairs(pts) do
- monitor.setCursorPos(1, line)
- lines[line] = txt
- monitor.write(lines[line])
- if line > height then
- for i = 1, line - 1 do
- lines[i] = lines[i + 1]
- end
- lines[line] = nil
- monitor.clear()
- for i = 1, line - 1 do
- monitor.setCursorPos(1, i)
- monitor.write(lines[i])
- end
- else
- line = line + 1
- end
- end
- end
- monitor.clear()
- exLog("root", "started system")
- while true do
- local id, msg = syslib.receiveRednet()
- local tag, pts = syslib.getMsgData(msg)
- if tag == "@log" then
- print("recv: ", msg)
- if pts[1] == nil or pts[2] == nil then
- if pts[1] == "clear" then
- monitor.clear()
- line=1
- else print("unsupported log-data: " .. msg)
- end
- else
- exLog(pts[1], pts[2])
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement