Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function mainLoop()
- local running = true
- local t = os.startTimer(1)
- while running do
- local event, p1, p2, p3, p4, p5 = os.pullEvent()
- if (event == "timer" and p1 == t) then
- local lst = peripheral.getNames()
- local mcTime = textutils.formatTime(os.time(), true)
- print(mcTime)
- for l = 1, #lst do
- if (peripheral.getType(lst[l]) == "monitor") then
- local mon = peripheral.wrap(lst[l])
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- mon.clear()
- local w, h = mon.getSize()
- local x = math.floor((w - #mcTime) / 2) + 1
- local y = math.floor((h - 1) / 2) + 1
- mon.setCursorPos(x, y)
- mon.write(mcTime)
- mon = nil
- end
- end
- lst = nil
- mcTime = nil
- t = os.startTimer(1)
- elseif (event == "char") then
- local c = string.lower(p1)
- if (c == "q") then
- running = nil
- end
- end
- end
- end
- mainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement