Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = term
- local w, h = term.getSize()
- -- Function to draw a window box
- local function drawBox(x, y, width, height, title)
- paintutils.drawFilledBox(x, y, x + width - 1, y + height - 1, colors.gray)
- paintutils.drawLine(x, y, x + width - 1, y, colors.lightGray)
- term.setCursorPos(x + 2, y)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- term.clearLine()
- term.write(title)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.white)
- end
- -- Function to center text
- local function drawCenteredText(y, text)
- local x = math.floor((w - #text) / 2)
- term.setCursorPos(x, y)
- term.write(text)
- end
- -- Function to show a message box
- local function showMessageBox(title, message)
- term.setBackgroundColor(colors.black)
- term.clear()
- drawBox(10, 5, w - 20, 6, title)
- drawCenteredText(7, message)
- drawCenteredText(9, "Press Enter to continue...")
- io.read()
- end
- -- Function to display a loading bar
- local function showLoadingBar(message, totalSteps)
- local barWidth = w - 10
- drawBox(5, h / 2 - 2, barWidth, 5, "System Recovery")
- for step = 1, totalSteps do
- term.setCursorPos(7, h / 2)
- term.write(message)
- term.setCursorPos(7, h / 2 + 1)
- term.write("[")
- for i = 1, barWidth - 8 do
- if i <= (step / totalSteps) * (barWidth - 8) then
- term.write("=")
- else
- term.write(" ")
- end
- end
- term.write("] " .. math.floor((step / totalSteps) * 100) .. "%")
- sleep(0.1)
- end
- end
- -- Full System Recovery
- local function fullSystemRecovery()
- showLoadingBar("Recovering system...", 50)
- showMessageBox("Recovery Complete", "Doggy OS has been restored successfully.")
- end
- -- Factory Reset (Wipes all except /disk/users/)
- local function wipeDataAndResetFactoryDefaults()
- showMessageBox("Warning", "This will erase all data except /disk/users/")
- showLoadingBar("Resetting to factory defaults...", 50)
- showMessageBox("Factory Reset Complete", "The system is now reset and ready for setup.")
- shell.run("/disk/setup")
- end
- -- Recovery Menu
- local function recoveryMenu()
- while true do
- term.setBackgroundColor(colors.black)
- term.clear()
- drawBox(5, 3, w - 10, 8, "Recovery Options")
- drawCenteredText(5, "1. Full System Recovery")
- drawCenteredText(6, "2. Factory Reset")
- drawCenteredText(7, "3. Exit")
- term.setCursorPos(5, 10)
- local choice = tonumber(io.read())
- if choice == 1 then
- fullSystemRecovery()
- elseif choice == 2 then
- wipeDataAndResetFactoryDefaults()
- elseif choice == 3 then
- break
- else
- showMessageBox("Error", "Invalid choice. Please try again.")
- end
- end
- end
- -- Power Menu (Reboot / Shutdown)
- local function powerMenu()
- term.setBackgroundColor(colors.black)
- term.clear()
- drawBox(5, 3, w - 10, 6, "Power Options")
- drawCenteredText(5, "1. Reboot System")
- drawCenteredText(6, "2. Shutdown System")
- term.setCursorPos(5, 8)
- local choice = tonumber(io.read())
- if choice == 1 then
- os.reboot()
- elseif choice == 2 then
- os.shutdown()
- else
- showMessageBox("Error", "Invalid choice.")
- end
- end
- -- Main Menu
- local function mainMenu()
- while true do
- term.setBackgroundColor(colors.black)
- term.clear()
- drawBox(5, 3, w - 10, 8, "Doggy OS Recovery")
- drawCenteredText(5, "1. Recovery Options")
- drawCenteredText(6, "2. Power Options")
- drawCenteredText(7, "3. Exit")
- term.setCursorPos(5, 10)
- local choice = tonumber(io.read())
- if choice == 1 then
- recoveryMenu()
- elseif choice == 2 then
- powerMenu()
- elseif choice == 3 then
- break
- else
- showMessageBox("Error", "Invalid choice. Please try again.")
- end
- end
- end
- mainMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement