zamkamec

center2

Sep 22nd, 2023 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. local monitor = peripheral.wrap("top")
  2.  
  3. local function centerText(text)
  4. local x,y = monitor.getSize()
  5. local x2,y2 = monitor.getCursorPos()
  6. monitor.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  7. monitor.write(text)
  8. end
  9.  
  10. centerText("Hello World")
Advertisement
Add Comment
Please, Sign In to add comment