DabDaddy6223

terminal_api

Aug 3rd, 2026 (edited)
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.50 KB | None | 0 0
  1. TERM_WIDTH, TERM_HEIGHT = term.getSize()
  2.  
  3. function term_PrintCentered(y, str)
  4.    local x = math.floor((TERM_WIDTH - string.len(str)) / 2)
  5.    term.setCursorPos(x, y)
  6.    term.clearLine()
  7.    term.write(str)
  8. end
  9.  
  10. function term_PrintThird(y, third, str)
  11.     local third_width = TERM_WIDTH / 3
  12.  
  13.     -- Centre position of the requested third
  14.     local centre_x = (third - 0.5) * third_width
  15.  
  16.     local x = math.floor(centre_x - (#str / 2))
  17.  
  18.     term.setCursorPos(x, y)
  19.     term.write(str)
  20. end
Advertisement
Add Comment
Please, Sign In to add comment