local function explodeString(d,p) local t, ll t = {} ll = 0 if (#p == 1) then return {p} end while true do l = string.find(p,d,ll,true) if l ~= nil then table.insert(t, string.sub(p,ll,l-1)) ll = l + 1 else table.insert(t, string.sub(p,ll)) break end end return t end local function printUsage() local filePath = shell.getRunningProgram() if string.find(filePath, "/") ~= nil then local path = explodeString("/", shell.getRunningProgram()) programName = path[#path] else programName = filePath end print("Usage:") print(programName.." ") end tArgs = { ... } if #tArgs ~= 2 then printUsage() return end if not http then print("This program requires http API") print("Please enable in the mod config") return end local code = tArgs[1] local filename = tArgs[2] local path = shell.resolve(filename) if fs.exists(path) then print("File already exists") return end write("Connecting to site... ") local response = http.get("http://wilsonbits.com/scripts/"..textutils.urlEncode(code)) if response then print("Success") local sCode = response.readAll() response.close() local file = fs.open(filename, "w") file.write(sCode) file.close() print("Downloaded as "..filename) else print("Failed") end