edoreld

Untitled

Oct 12th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1.  
  2.  
  3. --this function will print the text in the centre of the current line of the monitor connected on the specified side
  4. local monitorprintcentred = function(text, side)
  5. local monitor = peripheral.wrap("bottom")
  6. local maxw, maxh = monitor.getSize() --screen dimensions
  7. local curx, cury = monitor.getCursorPos() --cursor pos
  8.  
  9. monitor.setCursorPos((maxw-#text)/2,cury) --set it to the point where write will make the text centred
  10. monitor.write(text) --write the text
  11. monitor.setCursorPos(curx,cury+1) --return the cursor to the same position on the next line
  12. end
  13.  
  14. local monitor = peripheral.wrap("bottom") -- makes 'monitor' refer to the monitor on the left side
  15. local maxw, maxh = monitor.getSize() --screen dimensions
  16.  
  17. while true do
  18. monitor.clear()
  19. monitor.setCursorPos(1,math.floor(maxh/2))--set cursor to the start of the upper middle line
  20.  
  21. monitorprintcentred("Welcome To","left")--print centred on that line
  22. monitorprintcentred("Metroid Station","left")--print centred on the next line
  23.  
  24. os.sleep(30)
  25. end
Advertisement
Add Comment
Please, Sign In to add comment