Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap("right") -- Wrap the monitor on the right
- local w, h = term.getSize()
- -- Function to center text horizontally
- local function centerText(y, text, output, width)
- local x = math.floor((width - #text) / 2)
- output.setCursorPos(x, y)
- output.write(text)
- end
- -- Function to draw the spinner animation
- local function drawSpinner(x, y, duration, output, monitor, monitorSpinnerX, monitorSpinnerY)
- local spinnerFrames = {
- "[ ]",
- "[= ]",
- "[== ]",
- "[=== ]",
- "[====]",
- "[ ===]",
- "[ ==]",
- "[ =]",
- "[ ]",
- "[ =]",
- "[ ==]",
- "[ ===]",
- "[====]",
- "[=== ]",
- "[== ]",
- "[= ]"
- }
- local delay = 0.1
- local frameCount = #spinnerFrames
- local spinnerIndex = 1
- local startTime = os.clock()
- while os.clock() - startTime < duration do
- -- Draw spinner on terminal
- output.setCursorPos(x, y)
- output.write(spinnerFrames[spinnerIndex])
- -- Draw spinner on the monitor
- if monitor then
- monitor.setCursorPos(monitorSpinnerX, monitorSpinnerY)
- monitor.write(spinnerFrames[spinnerIndex])
- -- Display "Connecting..." under the spinner
- monitor.setCursorPos(monitorSpinnerX - 4, monitorSpinnerY + 1)
- monitor.write("Connecting...")
- end
- 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, output, width)
- for i, line in ipairs(dogImage) do
- centerText(y + i - 1, line, output, width)
- end
- end
- -- Function to draw the shutdown screen
- local function drawShutdownScreen(output, monitor)
- output.setBackgroundColor(colors.black)
- output.clear()
- output.setTextColor(colors.white)
- local artHeight = #dogImage
- local artY = math.floor((h - artHeight) / 2)
- drawASCIIArt(artY, output, w)
- if monitor then
- local monitorW, monitorH = monitor.getSize()
- monitor.setBackgroundColor(colors.black)
- monitor.clear()
- monitor.setTextColor(colors.white)
- -- Adjust text scale for smaller size
- monitor.setTextScale(1.2)
- -- Draw ASCII art on the monitor
- local monitorArtY = math.floor((monitorH - artHeight) / 2) - 2
- drawASCIIArt(monitorArtY, monitor, monitorW)
- -- Calculate spinner position on the monitor
- local monitorSpinnerX = math.floor((monitorW - 6) / 2)
- local monitorSpinnerY = monitorArtY + artHeight + 1
- drawSpinner(math.floor(w / 2) - 3, artY + artHeight + 2, 9, output, monitor, monitorSpinnerX, monitorSpinnerY)
- else
- -- Calculate spinner position on the terminal
- local spinnerX = math.floor(w / 2) - 3
- local spinnerY = artY + artHeight + 2
- drawSpinner(spinnerX, spinnerY, 9, output, nil, nil, nil)
- end
- end
- -- Main program
- if monitor then
- monitor.setTextScale(1.2) -- Smaller text scale for the monitor
- end
- drawShutdownScreen(term, monitor)
- -- Clear screen after shutdown
- term.setBackgroundColor(colors.black)
- term.clear()
- -- Shutdown the computer
- shell.run("disk/os/lock.lua")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement