Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. local monitorprintcentred = function(text, side)
  2. local monitor = peripheral.wrap(side)
  3. local maxw, maxh = monitor.getSize() --screen dimensions
  4. local curx, cury = monitor.getCursorPos() --cursor pos
  5.  
  6. monitor.setCursorPos((maxw-#text)/2,cury) --set it to the point where write will make the text centred
  7. monitor.write(text) --write the text
  8. monitor.setCursorPos(curx,cury+1) --return the cursor to the same position on the next line
  9. end
  10.  
  11. local monitor = peripheral.wrap("left") -- makes 'monitor' refer to the monitor on the left side
  12. local maxw, maxh =monitor.getSize() --screen dimensions
  13. monitor.setCursorPos(1,math.floor(maxh/2))--set cursor to the start of the upper middle line
  14.  
  15. monitorprintcentred("ATM","back")--print centred on that line
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement