Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Clear the screen and set up colors
- term.clear()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- -- Define the width and height of the screen
- local width, height = term.getSize()
- -- Helper function to center text on the screen
- local function centerText(y, text, textColor)
- local x = math.floor((width - #text) / 2)
- term.setCursorPos(x, y)
- term.setTextColor(textColor)
- term.write(text)
- end
- -- Define the dog ASCII art with white color and @ for eyes
- local dogArt = {
- " |\\_/| ",
- " | @ @ ",
- " | <> _ ",
- " | _/\\------____ ((| |))",
- " | `--' | ",
- " _____|_ ___| |___. ",
- "/_/_____/____/_______| "
- }
- local startLine = math.floor((height - #dogArt) / 2) - 2
- -- Display the dog ASCII art with white color
- term.setTextColor(colors.white)
- for i, line in ipairs(dogArt) do
- centerText(startLine + i, line, colors.white)
- end
- -- Display the "Insert Disk" message
- centerText(startLine + #dogArt + 2, "Insert disk", colors.white)
- -- Wait a moment to let the user see the "Insert Disk" message
- sleep(2)
- -- Check if /disk2/ exists
- if fs.exists("/disk2/") then
- -- Display the confirmation prompt for update
- term.setCursorPos(1, height)
- term.setTextColor(colors.yellow)
- term.write("Press 'Y' to proceed with the update, 'N' to cancel: ")
- -- Wait for user input
- local event, key = os.pullEvent("key")
- if key == keys.y then
- -- User confirmed to proceed with the update
- centerText(startLine + #dogArt + 2, "Emergency System Update...", colors.white)
- -- Simulate progress with an animated progress bar
- local progressBarWidth = 30
- local progressBarStartY = startLine + #dogArt + 4
- for i = 1, progressBarWidth do
- local progress = math.floor((i / progressBarWidth) * 100)
- local bar = string.rep("=", i) .. string.rep(" ", progressBarWidth - i)
- -- Clear previous progress bar line
- term.setCursorPos(1, progressBarStartY)
- term.write(string.rep(" ", width))
- -- Display updated progress bar
- term.setCursorPos(math.floor((width - progressBarWidth) / 2), progressBarStartY)
- term.setTextColor(colors.green)
- term.write("[" .. bar .. "] " .. progress .. "%")
- -- Wait a bit to simulate progress
- sleep(0.5)
- end
- -- Wait for additional 15 seconds to simulate finalizing the update
- sleep(15)
- elseif key == keys.n then
- -- User canceled the update
- centerText(startLine + #dogArt + 2, "Update canceled. Rebooting...", colors.red)
- -- Wait for 5 seconds to let the user see the cancellation message
- sleep(5)
- else
- -- If the input is not 'Y' or 'N', assume cancellation
- centerText(startLine + #dogArt + 2, "Invalid input. Update canceled.", colors.red)
- sleep(5)
- end
- else
- -- Display an error message if /disk2/ doesn't exist
- centerText(startLine + #dogArt + 2, "Disk not found. Unable to update.", colors.red)
- -- Wait for 5 seconds to let the user see the error message
- sleep(5)
- end
- -- Display the "Rebooting..." message
- centerText(startLine + #dogArt + 4, "Rebooting...", colors.white)
- -- Wait a few seconds before rebooting
- sleep(3)
- -- Reboot the system
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement