Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to check if a file exists
- local function fileExists(path)
- local file = fs.open(path, "r")
- if file then
- file.close()
- return true
- else
- return false
- end
- end
- -- Function to clear the screen
- local function clearScreen()
- term.clear()
- term.setCursorPos(1, 1)
- end
- -- Function to create a glitchy effect
- local function glitchyEffect()
- local width, height = term.getSize()
- local colors = {colors.white, colors.gray, colors.red, colors.blue, colors.green, colors.yellow}
- for _ = 1, 10 do
- term.setBackgroundColor(colors[math.random(#colors)])
- term.setTextColor(colors[math.random(#colors)])
- term.setCursorPos(math.random(1, width), math.random(1, height))
- print(string.char(math.random(32, 126)))
- sleep(0.05) -- Adjust the speed of the glitch effect here
- clearScreen()
- end
- end
- -- Function to display the Doggy OS boot manager GUI with glitchy effect
- local function displayGUI(message, options)
- clearScreen()
- glitchyEffect()
- -- Ensure the screen is cleared and set to default colors before showing the menu
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- clearScreen() -- Clear any remnants of the glitch effect
- term.setCursorPos(1, 1)
- print("Doggy OS Boot Manager")
- print("====================")
- print()
- print(message)
- print()
- for i, option in ipairs(options) do
- print(i .. ". " .. option)
- end
- end
- -- Function to shutdown the system
- local function shutdownSystem()
- clearScreen()
- displayGUI("Shutting down the system...", {})
- sleep(2) -- Simulate shutdown process
- os.shutdown()
- end
- -- Function to handle user choice
- local function getUserChoice(numOptions)
- local choice
- repeat
- term.setCursorPos(1, 10 + numOptions)
- print("Enter choice (1-" .. numOptions .. "): ")
- choice = tonumber(read())
- until choice and choice >= 1 and choice <= numOptions
- return choice
- end
- -- Main program logic
- local function main()
- local devCfgPath = "dev.cfg"
- local biosPath = "/disk/boot/BIOS"
- -- Check if dev.cfg exists
- if not fileExists(devCfgPath) then
- displayGUI("dev.cfg not found.", {"Run BIOS"})
- if fileExists(biosPath) then
- shell.run(biosPath)
- else
- print("Error: BIOS file not found.")
- end
- return
- end
- -- The disk paths to check
- local diskPath = "/disk2/startup"
- local startupFileFound = false
- -- Check if startup file exists on /disk2
- if fileExists(diskPath) or fileExists(diskPath .. ".lua") then
- startupFileFound = true
- end
- if startupFileFound then
- displayGUI("Boot Device found on /disk2.", {"Boot", "Shutdown system", "Reboot"})
- local choice = getUserChoice(3)
- if choice == 1 then
- clearScreen()
- if fileExists(diskPath .. ".lua") then
- shell.run(diskPath .. ".lua")
- elseif fileExists(diskPath) then
- shell.run(diskPath)
- end
- elseif choice == 2 then
- shutdownSystem()
- elseif choice == 3 then
- clearScreen()
- displayGUI("Rebooting...", {})
- shutdownSystem()
- end
- else
- displayGUI("No boot device found on /disk2.", {"Run BIOS"})
- if fileExists(biosPath) then
- shell.run(biosPath)
- else
- print("Error: BIOS file not found.")
- end
- end
- end
- -- Run the main function
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement