Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to draw a border
- local function drawBorder()
- term.clear()
- local w, h = term.getSize()
- for y = 1, h do
- term.setCursorPos(1, y)
- term.write("|")
- term.setCursorPos(w, y)
- term.write("|")
- end
- for x = 1, w do
- term.setCursorPos(x, 1)
- term.write("-")
- term.setCursorPos(x, h)
- term.write("-")
- end
- term.setCursorPos(1, 1)
- term.write("+")
- term.setCursorPos(w, 1)
- term.write("+")
- term.setCursorPos(1, h)
- term.write("+")
- term.setCursorPos(w, h)
- term.write("+")
- end
- -- Function to center text on the screen
- local function centerText(text, y)
- local w, _ = term.getSize()
- local x = math.floor((w - #text) / 2) + 1
- term.setCursorPos(x, y)
- term.write(text)
- end
- -- Function to show UEFI options menu
- local function showMenu()
- drawBorder()
- local _, h = term.getSize()
- centerText("Doggy OS UEFI Options", math.floor(h / 2) - 2)
- centerText("1. Recovery", math.floor(h / 2))
- centerText("2. Bootable devices", math.floor(h / 2) + 1)
- centerText("3. Shutdown", math.floor(h / 2) + 2)
- end
- -- Function to list bootable devices
- local function listBootableDevices()
- drawBorder()
- local _, h = term.getSize()
- centerText("Select Bootable Device", math.floor(h / 2) - 2)
- local devices = {}
- for _, side in ipairs({"top", "bottom", "left", "right", "front", "back"}) do
- if disk.isPresent(side) and fs.exists(disk.getMountPath(side) .. "/startup.lua") then
- table.insert(devices, side)
- end
- end
- for i, device in ipairs(devices) do
- centerText(i .. ". " .. device, math.floor(h / 2) - 1 + i)
- end
- if #devices == 0 then
- centerText("No bootable devices found", math.floor(h / 2))
- os.sleep(2)
- showMenu()
- else
- term.setCursorPos(1, math.floor(h / 2) + #devices + 1)
- term.write("Select a device number: ")
- local choice = tonumber(read())
- if choice and devices[choice] then
- shell.run(disk.getMountPath(devices[choice]) .. "/startup.lua")
- else
- listBootableDevices()
- end
- end
- end
- -- Function to handle menu selection
- local function handleSelection()
- while true do
- local event, key = os.pullEvent("key")
- if key == keys.one then
- shell.run("/disk/boot/Recovery.lua")
- elseif key == keys.two then
- listBootableDevices()
- elseif key == keys.three then
- os.shutdown()
- end
- end
- end
- -- Show menu
- showMenu()
- handleSelection()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement