Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Variables ]]--
- local onDisk = {}
- local diskPresent = false
- --[[ Function ]]--
- local function load_programs()
- local sides = peripheral.getNames()
- for a=1, #sides do
- if peripheral.getType(sides[a]) == "drive" then
- diskPresent = disk.hasData(sides[a])
- if diskPresent then
- onDisk = fs.list("disk")
- end
- break
- end
- end
- end
- local function run_program(prog)
- if prog then
- print("Running program \""..prog.."\"")
- sleep(0.8)
- shell.run("disk/"..prog)
- end
- end
- local function list_programs()
- if diskPresent then
- temp = {}
- for a=1, #onDisk do
- temp[tostring(a)] = onDisk[a]
- end
- temp.clear()
- term.setCursorPos(1, 1)
- for a=1, #onDisk do
- print(a..") "..temp[tostring(a)])
- end
- write("Enter Program Number > ")
- prog_number = read()
- if type(tonumber(prog_number)) == nil then
- printError("That's not a valid number!")
- else
- run_program(temp[tostring(prog_number)])
- end
- else
- printError("There are no programs in the floppy drive!")
- end
- end
- --[[ Main ]]--
- load_programs()
- list_programs()
Advertisement
Add Comment
Please, Sign In to add comment