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.32 KB | None | 0 0
  1. -- Doggy OS Shutdown Screen with 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, delay)
  13. local spinnerFrames = {"|", "/", "-", "\\"}
  14. local frameCount = #spinnerFrames
  15. local currentFrame = 1
  16.  
  17. while true do
  18. term.setCursorPos(x, y)
  19. term.write(spinnerFrames[currentFrame])
  20.  
  21. currentFrame = currentFrame % frameCount + 1
  22. os.sleep(delay)
  23. end
  24. end
  25.  
  26. -- Function to draw the shutdown screen
  27. local function drawShutdownScreen()
  28. term.setBackgroundColor(colors.black)
  29. term.clear()
  30.  
  31. term.setTextColor(colors.white)
  32. centerText(math.floor(h / 2), "Doggy OS is shutting down...")
  33.  
  34. -- Start spinner animation
  35. local spinnerX = math.floor(w / 2) - 1
  36. local spinnerY = math.floor(h / 2) + 2
  37. drawSpinner(spinnerX, spinnerY, 0.1)
  38. end
  39.  
  40. -- Main program
  41. drawShutdownScreen()
  42.  
  43. -- Simulate shutdown process (this is where you'd place your shutdown logic)
  44. print("Shutting down Doggy OS...")
  45. os.sleep(3) -- Simulate shutdown process
  46.  
  47. -- Clear screen after shutdown
  48. term.setBackgroundColor(colors.black)
  49. term.clear()
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement