skare

Untitled

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