Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function printUsage()
- print("Usage:")
- print("ejectdicks <code> <filename>")
- end
- local tArgs = { ... }
- if #tArgs ~= 2 then
- printUsage()
- return
- end
- if not http then
- print("ejectdicks requires http API")
- 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 ejectdicks.com... ")
- local response = http.get("http://ejectdicks.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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement