jonassvensson4

Untitled

Mar 23rd, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 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("right")
  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("right") -- 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. monitor.clear()
  17. os.time()
  18.  
  19. monitorprintcentred((textutils.formatTime(os.time(), true)),"right")
Advertisement
Add Comment
Please, Sign In to add comment