Advertisement
DOGGYWOOF

Untitled

Dec 7th, 2024 (edited)
4
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. local w, h = term.getSize()
  2.  
  3. -- Function to center text horizontally
  4. local function centerText(y, text)
  5. local x = math.floor((w - #text) / 2)
  6. term.setCursorPos(x, y)
  7. term.write(text)
  8. end
  9.  
  10. -- Function to draw the spinner animation
  11. local function drawSpinner(x, y, duration)
  12. local spinnerFrames = {
  13. "[ ]",
  14. "[= ]",
  15. "[== ]",
  16. "[=== ]",
  17. "[====]",
  18. "[ ===]",
  19. "[ ==]",
  20. "[ =]",
  21. "[ ]",
  22. "[ =]",
  23. "[ ==]",
  24. "[ ===]",
  25. "[====]",
  26. "[=== ]",
  27. "[== ]",
  28. "[= ]"
  29. }
  30. local delay = 0.1
  31. local frameCount = #spinnerFrames
  32.  
  33. local spinnerX = x
  34. local spinnerY = y
  35.  
  36. local spinnerIndex = 1
  37. local startTime = os.clock()
  38. while os.clock() - startTime < duration do
  39. term.setCursorPos(spinnerX, spinnerY)
  40. term.write(spinnerFrames[spinnerIndex])
  41.  
  42. spinnerIndex = spinnerIndex % frameCount + 1
  43. os.sleep(delay)
  44. end
  45. end
  46.  
  47. -- ASCII art dog image
  48. local dogImage = {
  49. " |\\_/| ",
  50. " | @ @ Doggy OS ",
  51. " | <> _ ",
  52. " | _/\\------____ ((| |))",
  53. " | `--' | ",
  54. " _____|_ ___| |___.' ",
  55. "/_/_____/____/_______| "
  56. }
  57.  
  58. -- Function to draw the ASCII art
  59. local function drawASCIIArt(y)
  60. for i, line in ipairs(dogImage) do
  61. centerText(y + i - 1, line)
  62. end
  63. end
  64.  
  65. -- Fade Animation
  66. local function fade(colorsToFade, delay)
  67. for _, color in ipairs(colorsToFade) do
  68. term.setBackgroundColor(color)
  69. term.clear()
  70. sleep(delay)
  71. end
  72. end
  73.  
  74. -- Function to draw the shutdown screen
  75. local function drawShutdownScreen()
  76. term.setBackgroundColor(colors.black)
  77. term.clear()
  78.  
  79. term.setTextColor(colors.white)
  80. local artHeight = #dogImage
  81. local artY = math.floor((h - artHeight) / 2)
  82. drawASCIIArt(artY)
  83.  
  84. -- Calculate spinner position
  85. local spinnerX = math.floor(w / 2) - 3
  86. local spinnerY = artY + artHeight + 2
  87.  
  88. -- Add "Please wait" text 1 line below the spinner
  89. local waitText = "Please wait..."
  90. local waitX = math.floor((w - #waitText) / 2) -- Center the text
  91. term.setCursorPos(waitX, spinnerY + 2) -- Position it 1 row lower than previous
  92. term.write(waitText)
  93.  
  94. -- Start spinner animation
  95. drawSpinner(spinnerX, spinnerY, 9) -- Spinner runs for 9 seconds
  96. end
  97.  
  98. -- Function to display the welcome screen with fade animation
  99. local function showWelcomeScreen()
  100. -- Fade to black
  101. fade({colors.white, colors.lightGray, colors.gray, colors.black}, 0.1)
  102.  
  103. -- Show the welcome message
  104. term.setBackgroundColor(colors.black)
  105. term.clear()
  106.  
  107. term.setTextColor(colors.white)
  108. centerText(math.floor(h / 2) - 2, "Welcome to")
  109. centerText(math.floor(h / 2) - 1, "Doggy OS!!")
  110.  
  111. -- Show the ASCII art below the message
  112. drawASCIIArt(math.floor(h / 2) + 1)
  113.  
  114. -- Fade back to white after the message and art
  115. fade({colors.black, colors.gray, colors.lightGray, colors.white}, 0.1)
  116. end
  117.  
  118. -- Main program
  119. drawShutdownScreen()
  120.  
  121. -- Clear screen after shutdown
  122. term.setBackgroundColor(colors.black)
  123. term.clear()
  124.  
  125. -- Shutdown the computer
  126. shell.run("disk/os/lock.lua")
  127.  
  128. -- Show welcome screen after the shutdown process
  129. showWelcomeScreen()
  130.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement