Humenius

ComputerCraft - Write Centered Text

Dec 12th, 2016
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.27 KB | None | 0 0
  1. function writeCenter(text, y, mon)
  2.   local w, h = mon.getSize() or term.getSize()
  3.   if mon then
  4.     mon.setCursorPos( math.ceil( w/2 - #text/2 + 1 ), y )
  5.     mon.write( text )
  6.   else
  7.     term.setCursorPos( math.ceil( w/2 - #text/2 ), y )
  8.     term.write( text )
  9.   end
  10. end
Advertisement
Add Comment
Please, Sign In to add comment