dveth

monitor

Nov 29th, 2020 (edited)
550
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local width = 18
  2. local height = 12
  3.  
  4. monitor = peripheral.wrap("right")
  5.  
  6. monitor.clear()
  7. monitor.setCursorPos(1,1)
  8.  
  9. function writeCenterText(text, lheight)
  10.     local mid = width / 2
  11.     monitor.setCursorPos(mid - (#text / 2), lheight)
  12.     monitor.write(text)
  13. end
  14.  
  15. writeCenterText("Testing", 5)
  16. writeCenterText("Testing1", 6)
  17.  
  18. local running = true
  19.  
  20. monitor.clear()
  21.  
  22. while(running) do
  23.     print("Enter your message:")
  24.     local input = read()
  25.     if(input == "quitNow") then
  26.         running = false
  27.     else
  28.         local text = input
  29.         print("Enter the width:")
  30.         local lwidth = tonumber(read())
  31.         print("Enter the height:")
  32.         local lheight = tonumber(read())
  33.         monitor.clear()
  34.         monitor.setCursorPos(lwidth, lheight)
  35.         monitor.write(text)
  36.     end
  37. end
RAW Paste Data