Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. --This program can be used to create a digital clock on a monitor peripheral
  2. --The monitor must be placed to the right of the computer
  3.  
  4. print("Running clock application. Hold ctrl + T to end.")
  5. local monitor = peripheral.wrap("back")
  6.  
  7. w, h = term.getSize()
  8. term.setCursorPos(math.floor(w - #text)/2, yPos)
  9.  
  10. monitor.setTextScale(4)
  11.  
  12. while true do
  13. local decimalTime = os.time()
  14. local hours = math.floor(decimalTime)
  15. local minutes = math.floor((decimalTime - hours) * 100 * 0.6)
  16.  
  17. local ampm
  18. if hours > 12 then
  19. hours = hours - 12
  20. ampm = "PM"
  21. else
  22. ampm = "AM"
  23. end
  24. monitor.clear()
  25. monitor.setCursorPos(1,1)
  26. if minutes < 10 then
  27. monitor.write(hours..":0"..minutes.." "..ampm)
  28. else
  29. monitor.write(hours..":"..minutes.." "..ampm)
  30. end
  31. sleep(2)
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement