Advertisement
DOGGYWOOF

Centered text

Jun 30th, 2024
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. -- Doggy OS Security Error
  2.  
  3. -- Function to draw a border
  4. local function drawBorder()
  5. term.clear()
  6. local w, h = term.getSize()
  7. for y = 1, h do
  8. term.setCursorPos(1, y)
  9. term.write("|")
  10. term.setCursorPos(w, y)
  11. term.write("|")
  12. end
  13. for x = 1, w do
  14. term.setCursorPos(x, 1)
  15. term.write("-")
  16. term.setCursorPos(x, h)
  17. term.write("-")
  18. end
  19. term.setCursorPos(1, 1)
  20. term.write("+")
  21. term.setCursorPos(w, 1)
  22. term.write("+")
  23. term.setCursorPos(1, h)
  24. term.write("+")
  25. term.setCursorPos(w, h)
  26. term.write("+")
  27. end
  28.  
  29. -- Function to center text on the screen
  30. local function centerText(text, y)
  31. local w, _ = term.getSize()
  32. local x = math.floor((w - #text) / 2) + 1
  33. term.setCursorPos(x, y)
  34. term.write(text)
  35. end
  36.  
  37. -- Function to show an error message
  38. local function showError()
  39. drawBorder()
  40. local _, h = term.getSize()
  41. centerText("Doggy OS Security Error", math.floor(h / 2))
  42. -- No need to show additional instructions
  43. while true do
  44. os.pullEvent("key")
  45. end
  46. end
  47.  
  48. -- Show error message
  49. showError()
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement