Advertisement
ivanzrer

CCT monitor v1

Oct 16th, 2024
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. -- argument handling
  2. args = {...}
  3. tInput = tostring(args[1])
  4. tSecond = tostring(args[2])
  5.  
  6. -- find monitor
  7. local monitor = peripheral.find("monitor")
  8.  
  9. -- prepare monitor
  10. monitor.setBackgroundcolor(colors.purple)
  11. monitor.setTextColor(colors.cyan)
  12. monitor.clear()
  13. monitor.setCursorPos(1, 1)
  14. monitor.setTextScale(2)
  15.  
  16. monSize = monitor.getSize()
  17. while monSize[1] < tInput do
  18.     tScale = tScale - 0.1
  19.     monitor.setTextScale(tScale)
  20.     print("trying ", tostring(tScale))
  21. end
  22.  
  23. monCenterX = monSize[1] / 2
  24. monCenterY = monSize[2] / 2
  25.  
  26. if tSecond then
  27.     while monSize[2] < tSecond do
  28.         tScale = tScale - 0.1
  29.         monitor.setTextScale(tScale)
  30.         print("trying ", tostring(tScale))
  31.     end
  32.  
  33.     -- two lines
  34.     -- line one prep
  35.     monitor.setCursorPos(monCenterX - #tInput, monCenterY - 1)
  36.     -- write
  37.     monitor.write(tInput)
  38.  
  39.     -- line two prep
  40.     monitor.setCursorPos(monCenterX - #tSecond, monCenterY)
  41.     -- write
  42.     monitor.write(tSecond)
  43.  
  44. else
  45.     -- single line prep
  46.     monitor.setCursorPos(monCenterX - #tInput, monCenterY)
  47. end
  48.  
  49.  
  50.  
  51.  
  52. monitor.write()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement