Advertisement
JcdShrimp

Untitled

Oct 14th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 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. monitor.setTextScale(4)
  8.  
  9. while true do
  10. local decimalTime = os.time()
  11. local hours = math.floor(decimalTime)
  12. local minutes = math.floor((decimalTime - hours) * 100 * 0.6)
  13.  
  14. local ampm
  15. if hours > 12 then
  16. hours = hours - 12
  17. ampm = "PM"
  18. else
  19. ampm = "AM"
  20. end
  21. monitor.clear()
  22. monitor.setCursorPos(1,1)
  23. if minutes < 10 then
  24. monitor.write(hours..":0"..minutes.." "..ampm)
  25. else
  26. monitor.write(hours..":"..minutes.." "..ampm)
  27. end
  28. sleep(2)
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement