Guest User

Untitled

a guest
Oct 15th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.47 KB | None | 0 0
  1. if #arg < 1 then
  2.   print("usage: clock [side of monitor]")
  3.   os.exit()
  4. end
  5.  
  6. monitor = peripheral.wrap(arg[1])
  7.  
  8. function drawTime()
  9.   time = os.time()
  10.   timeText = textutils.formatTime(time, true)
  11.  
  12.   -- horizontally center
  13.   w, h = monitor.getSize()
  14.   x = 1 + (w - 5) / 2 + (5 - string.len(timeText))
  15.   y = 1 + (h - 1) / 2
  16.  
  17.   -- draw
  18.   monitor.clear()
  19.   monitor.setCursorPos(x, y)
  20.   monitor.write(timeText)
  21. end
  22.  
  23. while true do
  24.   drawTime()
  25.   os.sleep(1)
  26. end
Add Comment
Please, Sign In to add comment