Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if #arg < 1 then
- print("usage: clock [side of monitor]")
- os.exit()
- end
- monitor = peripheral.wrap(arg[1])
- function drawTime()
- time = os.time()
- timeText = textutils.formatTime(time, true)
- -- horizontally center
- w, h = monitor.getSize()
- x = 1 + (w - 5) / 2 + (5 - string.len(timeText))
- y = 1 + (h - 1) / 2
- -- draw
- monitor.clear()
- monitor.setCursorPos(x, y)
- monitor.write(timeText)
- end
- while true do
- drawTime()
- os.sleep(1)
- end
Add Comment
Please, Sign In to add comment