Advertisement
TheRoyalDark

Untitled

Oct 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 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("Salle des machines","left")--print centred on that line
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement