Advertisement
ivanzrer

cctdv3

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