Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w, h = term.getSize()
- -- Function to center text horizontally
- local function centerText(y, text)
- local x = math.floor((w - #text) / 2)
- term.setCursorPos(x, y)
- term.write(text)
- end
- -- Function to draw the spinner animation
- local function drawSpinner(x, y, duration)
- local spinnerFrames = {
- "[ ]",
- "[= ]",
- "[== ]",
- "[=== ]",
- "[====]",
- "[ ===]",
- "[ ==]",
- "[ =]",
- "[ ]",
- "[ =]",
- "[ ==]",
- "[ ===]",
- "[====]",
- "[=== ]",
- "[== ]",
- "[= ]"
- }
- local delay = 0.1
- local frameCount = #spinnerFrames
- local spinnerX = x
- local spinnerY = y
- local spinnerIndex = 1
- local startTime = os.clock()
- while os.clock() - startTime < duration do
- term.setCursorPos(spinnerX, spinnerY)
- term.write(spinnerFrames[spinnerIndex])
- spinnerIndex = spinnerIndex % frameCount + 1
- os.sleep(delay)
- end
- end
- -- ASCII art dog image
- local dogImage = {
- " |\\_/| ",
- " | @ @ Doggy OS ",
- " | <> _ ",
- " | _/\\------____ ((| |))",
- " | `--' | ",
- " _____|_ ___| |___.' ",
- "/_/_____/____/_______| "
- }
- -- Function to draw the ASCII art
- local function drawASCIIArt(y)
- for i, line in ipairs(dogImage) do
- centerText(y + i - 1, line)
- end
- end
- -- Fade Animation
- local function fade(colorsToFade, delay)
- for _, color in ipairs(colorsToFade) do
- term.setBackgroundColor(color)
- term.clear()
- sleep(delay)
- end
- end
- -- Function to draw the shutdown screen
- local function drawShutdownScreen()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- local artHeight = #dogImage
- local artY = math.floor((h - artHeight) / 2)
- drawASCIIArt(artY)
- -- Calculate spinner position
- local spinnerX = math.floor(w / 2) - 3
- local spinnerY = artY + artHeight + 2
- -- Add "Please wait" text 1 line below the spinner
- local waitText = "Please wait..."
- local waitX = math.floor((w - #waitText) / 2) -- Center the text
- term.setCursorPos(waitX, spinnerY + 2) -- Position it 1 row lower than previous
- term.write(waitText)
- -- Start spinner animation
- drawSpinner(spinnerX, spinnerY, 9) -- Spinner runs for 9 seconds
- end
- -- Function to display the welcome screen with fade animation
- local function showWelcomeScreen()
- -- Fade to black
- fade({colors.white, colors.lightGray, colors.gray, colors.black}, 0.1)
- -- Show the welcome message
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- centerText(math.floor(h / 2) - 2, "Welcome to")
- centerText(math.floor(h / 2) - 1, "Doggy OS!!")
- -- Show the ASCII art below the message
- drawASCIIArt(math.floor(h / 2) + 1)
- -- Fade back to white after the message and art
- fade({colors.black, colors.gray, colors.lightGray, colors.white}, 0.1)
- end
- -- Main program
- drawShutdownScreen()
- -- Clear screen after shutdown
- term.setBackgroundColor(colors.black)
- term.clear()
- -- Shutdown the computer
- shell.run("disk/os/lock.lua")
- -- Show welcome screen after the shutdown process
- showWelcomeScreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement