Advertisement
ivanzrer

cct display v2

Oct 16th, 2024
35
0
17 hours
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 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. monSizeX = monitor.getSize(1)
  17. monSizeY = monitor.getSize(1)
  18.  
  19. while monSizeX < tInput do
  20.     tScale = tScale - 0.1
  21.     monitor.setTextScale(tScale)
  22.     print("trying ", tostring(tScale))
  23. end
  24.  
  25. monCenterX = monSizeX / 2
  26. monCenterY = monSizeY / 2
  27.  
  28. if tSecond then
  29.     while monSizeY < tSecond do
  30.         tScale = tScale - 0.1
  31.         monitor.setTextScale(tScale)
  32.         print("trying ", tostring(tScale))
  33.     end
  34.  
  35.     -- two lines
  36.     -- line one prep
  37.     monitor.setCursorPos(monCenterX - #tInput, monCenterY - 1)
  38.     -- write
  39.     monitor.write(tInput)
  40.  
  41.     -- line two prep
  42.     monitor.setCursorPos(monCenterX - #tSecond, monCenterY)
  43.     -- write
  44.     monitor.write(tSecond)
  45.  
  46. else
  47.     -- single line prep
  48.     monitor.setCursorPos(monCenterX - #tInput, monCenterY)
  49. end
  50.  
  51.  
  52.  
  53.  
  54. monitor.write()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement