Advertisement
Guest User

Untitled

a guest
Mar 21st, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 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 side = "bottom"
  3. local monitorprintcentred = function(text, side)
  4. local monitor = peripheral.wrap(side)
  5. local maxw, maxh = monitor.getSize() --screen dimensions
  6. local curx, cury = monitor.getCursorPos() --cursor pos
  7.  
  8. monitor.setCursorPos((maxw-#text)/2,cury) --set it to the point where write will make the text centred
  9. monitor.write(text) --write the text
  10. monitor.setCursorPos(curx,cury+1) --return the cursor to the same position on the next line
  11. end
  12.  
  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. monitor.setTextColor(colors.green)
  17. monitorprintcentred("Air Lock 1","left")--print centred on that line
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement