Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local os = require("os")
- local function diskInserted()
- local drives = component.list("drive")
- for address in drives do
- local drive = component.proxy(address)
- if drive.isDiskPresent() then
- return address
- end
- end
- return nil
- end
- local function bootFromDisk(driveAddress)
- local drive = component.proxy(driveAddress)
- if drive.isDiskPresent() then
- local mountPath = "/mnt/" .. driveAddress:sub(1, 3)
- local bootFilePath = mountPath .. "/boot.lua"
- local file = io.open(bootFilePath, "r")
- if file then
- local code = file:read("*a")
- file:close()
- local func, loadError = load(code)
- if func then
- func() -- Execute the boot script
- end
- end
- end
- end
- -- Main BIOS loop
- local status = "No disk detected. Please insert the disk."
- while true do
- local driveAddress = diskInserted()
- if driveAddress then
- status = "Disk detected in drive " .. driveAddress .. ". Attempting to boot from the disk..."
- bootFromDisk(driveAddress)
- break
- else
- os.sleep(2) -- Check every 2 seconds
- end
- end
- -- End of BIOS script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement