TheGameBoy_95

Untitled

May 18th, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. -- Min width required (IE: 10:00 PM)
  2. minWidthReq = 8
  3. minHeightReq = 2
  4.  
  5. -- Figure out where our monitor is
  6. monitorSide = nil
  7. monitor = nil
  8.  
  9. if peripheral.getType("left") == "monitor" then
  10. monitorSide = "left"
  11. elseif peripheral.getType("right") == "monitor" then
  12. monitorSide = "right"
  13. elseif peripheral.getType("top") == "monitor" then
  14. monitorSide = "top"
  15. elseif peripheral.getType("bottom") == "monitor" then
  16. monitorSide = "bottom"
  17. elseif peripheral.getType("front") == "monitor" then
  18. monitorSide = "front"
  19. elseif peripheral.getType("back") == "monitor" then
  20. monitorSide = "back"
  21. end
  22.  
  23. screenWidth = 0
  24. screenHeight = 0
  25.  
  26. -- If we have one, redirect term to it
  27. if monitorSide ~= nil then
  28. monitor = peripheral.wrap(monitorSide)
  29. term.redirect(monitor)
  30.  
  31. local scale = 5.5
  32.  
  33. repeat
  34. scale = scale - 0.5
  35. monitor.setTextScale(scale)
  36. screenWidth, screenHeight = term.getSize()
  37. until screenWidth > minWidthReq and screenHeight > minHeightReq
  38. end
  39.  
  40. -- Determine our screen size
  41. screenWidth, screenHeight = term.getSize()
  42. yPos = screenHeight - minHeightReq
  43. yPos = math.floor(yPos / 2)
  44.  
  45. -- Main loop
  46. while true do
  47. term.clear()
  48.  
  49. local time = os.time()
  50. time = textutils.formatTime(time, false)
  51.  
  52. local xPos = screenWidth - string.len(time)
  53. xPos = math.ceil(xPos / 2)
  54. term.setCursorPos(xPos + 1, yPos + 2)
  55. print(time)
  56.  
  57. sleep(.1)
  58. end
Add Comment
Please, Sign In to add comment