Advertisement
DOGGYWOOF

Untitled

Jun 30th, 2024 (edited)
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. -- Doggy OS Shutdown Screen with Advanced Spinner
  2. local w, h = term.getSize()
  3.  
  4. -- Function to center text horizontally
  5. local function centerText(y, text)
  6. local x = math.floor((w - #text) / 2)
  7. term.setCursorPos(x, y)
  8. term.write(text)
  9. end
  10.  
  11. -- Function to draw the spinner animation
  12. local function drawSpinner(x, y, duration)
  13. local spinnerFrames = {
  14. "[ ]",
  15. "[= ]",
  16. "[== ]",
  17. "[=== ]",
  18. "[====]",
  19. "[ ===]",
  20. "[ ==]",
  21. "[ =]",
  22. "[ ]",
  23. "[ =]",
  24. "[ ==]",
  25. "[ ===]",
  26. "[====]",
  27. "[=== ]",
  28. "[== ]",
  29. "[= ]"
  30. }
  31. local delay = 0.1
  32. local frameCount = #spinnerFrames
  33.  
  34. local spinnerX = x
  35. local spinnerY = y
  36.  
  37. local spinnerIndex = 1
  38. local startTime = os.clock()
  39. while os.clock() - startTime < duration do
  40. term.setCursorPos(spinnerX, spinnerY)
  41. term.write(spinnerFrames[spinnerIndex])
  42.  
  43. spinnerIndex = spinnerIndex % frameCount + 1
  44. os.sleep(delay)
  45. end
  46. end
  47.  
  48. -- Function to draw the shutdown screen
  49. local function drawShutdownScreen()
  50. term.setBackgroundColor(colors.black)
  51. term.clear()
  52.  
  53. term.setTextColor(colors.white)
  54. centerText(math.floor(h / 2), "Doggy OS is shutting down...")
  55.  
  56. -- Calculate spinner position
  57. local spinnerX = math.floor(w / 2) - 3
  58. local spinnerY = math.floor(h / 2) + 2
  59.  
  60. -- Start spinner animation
  61. drawSpinner(spinnerX, spinnerY, 5) -- Spinner runs for 5 seconds
  62. end
  63.  
  64. -- Main program
  65. drawShutdownScreen()
  66.  
  67. -- Clear screen after shutdown
  68. term.setBackgroundColor(colors.black)
  69. term.clear()
  70.  
  71. -- Shutdown the computer
  72. os.shutdown()
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement