Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- For "MyFile" put inside the quotes the name of the file you want to run, including the extension
- example: "myFile.ficlua"
- You can also leave the field blank "" and it will run the first file it finds.
- For "MyDrive" put inside the quote the ID of the drive you files are stored in
- The drive ID is the same as the folder id in the SaveGames/Computer/<ID>
- Leave it blank and it will find a workable drive by itself
- NOTE: this can cause it find the wrong drive if you have a drive and a floppy
- ]]
- local myFile = ""
- local myDrive = ""
- -- [[ CODE DO NOT TOUCH ]] --
- -- init filesystem
- local _G = _G
- local fs = _G.filesystem
- local computer = _G.computer
- if fs.initFileSystem("/dev") == false then
- computer.panic("Cannot initialize /dev!")
- end
- -- find drive if one isn't stated
- if (myDrive:len() == 0) then
- for _,f in pairs(fs.childs("/dev")) do
- if f ~= "serial" then
- myDrive = f
- break
- end
- end
- end
- -- mount drive
- if (myDrive:len() > 0) then
- local ch = fs.mount("/dev/"..myDrive, "/")
- if (not ch) then
- computer.panic(myDrive .. " could not be found!")
- end
- else
- computer.panic("No HardDrive Found!")
- end
- -- find a file if one isn't stated
- if (myFile:len() == 0) then
- for _,f in pairs(fs.childs("/")) do
- if fs.isFile(f) then
- myFile = f
- break
- end
- end
- end
- -- run the file
- if (myFile:len() > 0) then
- if (fs.exists(myFile)) then
- fs.doFile(myFile)
- else
- computer.panic(myFile .. " could not be found!")
- end
- else
- computer.panic("No file found!")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement