poke5555

Untitled

Apr 23rd, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. --this function will print the text in the centre of the current line of the monitor connected on the specified side
  2. local monitorprintcentred = function(text, side)
  3. local monitor = peripheral.wrap(side)
  4. local maxw, maxh = monitor.getSize() --screen dimensions
  5. local curx, cury = monitor.getCursorPos() --cursor pos
  6.  
  7. monitor.setCursorPos((maxw-#text)/2,cury) --set it to the point where write will make the text centred
  8. monitor.write(text) --write the text
  9. monitor.setCursorPos(curx,cury+1) --return the cursor to the same position on the next line
  10. end
  11.  
  12. local monitor = peripheral.wrap("left") -- makes 'monitor' refer to the monitor on the left side
  13. local maxw, maxh =monitor.getSize() --screen dimensions
  14. monitor.setCursorPos(1,math.floor(maxh/2))--set cursor to the start of the upper middle line
  15.  
  16. monitorprintcentred("Welcome To","left")
  17. monitorprintcentred("The Sleeping Quarters","left")
  18. monitorprintcentred(" ","left")
  19. monitorprintcentred(" /|________/|","left")
  20. monitorprintcentred(" // / //|","left")
  21. monitorprintcentred(" |/_/______|//! ","left")
  22. monitorprintcentred(" |_________|/","left")
  23. monitorprintcentred(" ! !","left")
Advertisement
Add Comment
Please, Sign In to add comment