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
- -- Helper function to draw a loading bar
- local function drawLoadingBar(y, percent)
- local barWidth = math.floor(width * 0.6) -- Loading bar is 60% of the screen width
- local barX = math.floor((width - barWidth) / 2)
- term.setCursorPos(barX, y)
- term.write("[")
- for i = 1, barWidth - 2 do
- if i <= (barWidth - 2) * (percent / 100) then
- term.write("=")
- else
- term.write(" ")
- end
- end
- term.write("]")
- end
- -- Helper function to display an error screen
- local function showErrorScreen()
- term.clear()
- term.setTextColor(colors.red)
- print("ERROR: Failed to Repair Recovery Partition")
- sleep(5)
- 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 "Initializing..." message in white
- centerText(startLine + #dogArt + 2, "Initializing...", colors.white)
- -- Wait for 4 seconds to simulate initialization
- sleep(4)
- -- Clear the "Initializing..." message
- term.clearLine()
- centerText(startLine + #dogArt + 2, "", colors.white)
- -- Display the "Repairing Recovery Partition..." message in white
- centerText(startLine + #dogArt + 2, "Repairing Recovery Partition...", colors.white)
- -- Simulate a loading bar for the repair process
- for i = 1, 100, 5 do
- drawLoadingBar(startLine + #dogArt + 4, i)
- sleep(0.75) -- Simulate repair process with each increment
- end
- -- Attempt to copy the recovery files to the root directory
- local success = pcall(function()
- fs.delete("/recovery") -- Ensure previous recovery files are deleted
- fs.copy("/disk", "/recovery")
- end)
- -- If the copy fails, show an error screen
- if not success then
- showErrorScreen()
- return -- Stop execution after showing error
- end
- -- Clear the loading bar and "Repairing..." message
- term.clearLine()
- centerText(startLine + #dogArt + 2, "", colors.white)
- -- Display the "Recovery Partition Repaired Successfully!" message in white
- centerText(startLine + #dogArt + 2, "Recovery Partition Repaired Successfully!", colors.white)
- -- Display the countdown message
- for i = 5, 0, -1 do
- centerText(startLine + #dogArt + 4, "Rebooting in " .. i .. "...", colors.white)
- sleep(1)
- end
- -- Display the "Rebooting..." message in white
- -- Wait for 3 seconds before rebooting
- -- Reboot the system
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement