Advertisement
Noobular

Centered Text [CC]

May 20th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.26 KB | None | 0 0
  1. local function centerText(text)
  2. m = peripheral.wrap("back")
  3. local x,y = m.getSize()
  4. local x2,y2 = m.getCursorPos()
  5. m.clear()
  6. m.setTextColor(colors.red)
  7. m.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  8. m.write(text)
  9. end
  10.  
  11. centerText("Hello World")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement