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 ASCII art
- local dogImage = {
- " |\_/| ",
- " | @ @ Doggy OS ",
- " | <> _ ",
- " | _/\------____ ((| |))",
- " | `--' | ",
- " _____|_ ___| |___.' ",
- "/_/_____/____/_______| "
- }
- local function drawASCIIArt(y)
- for i, line in ipairs(dogImage) do
- centerText(y + i - 1, line)
- end
- end
- -- Function to draw a loading bar
- local function drawLoadingBar(y, percent)
- local barWidth = math.floor(w * 0.6)
- local barX = math.floor((w - barWidth) / 2)
- local completed = math.floor(barWidth * percent)
- term.setCursorPos(barX, y)
- term.write("[")
- term.write(string.rep("=", completed))
- term.write(string.rep(" ", barWidth - completed))
- term.write("]")
- end
- -- Function to simulate BIOS update
- local function biosUpdate()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- local artHeight = #dogImage
- local artY = math.floor((h - artHeight) / 2) - 1
- drawASCIIArt(artY)
- local loadingBarY = artY + artHeight + 2
- centerText(loadingBarY - 1, "Updating BIOS...")
- for i = 1, 100 do
- drawLoadingBar(loadingBarY, i / 100)
- os.sleep(0.05) -- Simulate update progress
- end
- os.sleep(1)
- centerText(loadingBarY + 2, "Update Complete! Restarting...")
- os.sleep(2)
- end
- -- Function to check and perform firmware update
- local function checkFirmwareUpdate()
- if fs.exists(".FWupdate") then
- biosUpdate()
- -- Download the new startup file
- local handle = http.get("https://pastebin.com/raw/S8BwCeEb")
- if handle then
- local data = handle.readAll()
- handle.close()
- -- Save the new startup file
- local file = fs.open("startup", "w")
- file.write(data)
- file.close()
- -- Remove the .FWupdate file
- fs.delete(".FWupdate")
- else
- error("Failed to download BIOS update.")
- end
- -- Restart the system
- os.reboot()
- end
- end
- -- Placeholder function for boot animation
- local function loadBootAnimation()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- local artHeight = #dogImage
- local artY = math.floor((h - artHeight) / 2)
- drawASCIIArt(artY)
- local spinnerX = math.floor(w / 2) - 3
- local spinnerY = artY + artHeight + 2
- centerText(spinnerY, "Booting...")
- os.sleep(2) -- Simulate boot delay
- end
- -- Main function
- local function main()
- checkFirmwareUpdate()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- centerText(math.floor(h / 2), "Press DEL to show startup options")
- local timer = os.startTimer(2.5)
- while true do
- local event, param = os.pullEvent()
- if event == "key" and param == keys.delete then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- centerText(math.floor(h / 2), "Loading startup menu...")
- os.sleep(2.5)
- shell.run("disk/boot/boot-options")
- return
- elseif event == "timer" and param == timer then
- loadBootAnimation()
- return
- end
- end
- end
- -- Run the main function
- main()
- -- Clear screen after shutdown
- term.setBackgroundColor(colors.black)
- term.clear()
- -- Load lockscreen
- shell.run("disk/os/lock.lua")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement