Flaghacker

print text

May 24th, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. --[[Settings]]--
  2. local text =
  3.     {
  4.     "line1",
  5.     "line2",
  6.     "line3"
  7.     }
  8. local monitorSide = "top"
  9. local textScale = 1
  10.  
  11. --[[Variables & peripherals]]--
  12. monitor = peripheral.wrap(monitorSide)
  13.  
  14. --[[Functions]]--
  15. local function round(number)
  16.     return math.floor(number + 0.5)
  17. end
  18.  
  19. --[[Main program]]--
  20. monitor.clear()
  21.  
  22. local width, height = monitor.getSize()
  23. monitor.setTextScale(textScale)
  24. local yPos = round(height / 2 - #text / 2)
  25.  
  26. for i, textLine in pairs(text) do
  27.     print(textLine)
  28.     local xPos = round(width / 2 - #textLine / 2)
  29.     monitor.setCursorPos(xPos, yPos + i)
  30.     monitor.write(textLine)
  31. end
Advertisement
Add Comment
Please, Sign In to add comment