Advertisement
Plazter

Text Manipulation (Center, new line)

Mar 31st, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. m = peripheral.find("monitor")
  2. function centerText(text)
  3.     local x2,y2 = term.getCursorPos()
  4.     local x,y = term.getSize()
  5.     term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  6.     write(text)
  7. end
  8.  
  9. function mWrite(text)
  10.     local x2,y2 = m.getCursorPos()
  11.     local x,y = m.getSize()
  12.     m.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  13.     m.write(text)  
  14. end
  15.  
  16. function clear()
  17.     term.clear()
  18.     term.setCursorPos(1,1)
  19. end
  20.  
  21. function mClear()
  22.     m.clear()
  23.     m.setCursorPos(1,1)
  24. end
  25.  
  26. function nLine()
  27.     line = line + 1
  28.     x, y = term.getSize()
  29.     x2,y2 = term.getCursorPos()
  30.    
  31.     if x2 == x then
  32.     nLine()
  33.     end
  34. end
  35.  
  36. function mNline()
  37.     mLine = mLine + 1
  38.     m.setCursorPos(1,mLine)
  39. end
  40.  
  41. function mTxt(text)
  42.     x, y = m.getSize()
  43.     x2,y2 = m.getCursorPos()
  44.    
  45.     if x2 == x then
  46.     nLine()
  47.     end
  48.     m.write(text)
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement