Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --this program takes an argument in the form of a url to download to a tape
- --2nd arg specifies where in the tape to start writing at
- args={...}--{'https://kitomas.neocities.org/YMO-Tong_Poo6.txt'}
- local tape=peripheral.find("tape_drive")
- local multi=' '
- local inc=6000
- term.clear()
- term.setCursorPos(1,1)
- if #args > 0 then
- if tape then
- if tape.isReady() then
- print("Verifying URL...")
- local ok, err = http.checkURLAsync(args[1])
- if ok then
- print("Fetching URL contents... (This may take a while)")
- local request, err = http.get(args[1],nil,true)
- if request then
- print("Preparing Tape Drive...")
- os.sleep(.2) --so that you can see the text before the screen clears
- local counter,yield=0,0
- local size=tape.getSize()
- tape.stop()
- tape.seek(-size-9999)
- if tonumber(args[2]) ~= nil then tape.seek(tonumber(args[2])) end
- while counter < size and multi ~= nil do
- term.setCursorPos(1,3)
- term.write("Writing: "..counter.."/"..size.." ")
- multi=request.read(inc)
- if multi ~= nil then
- tape.write(multi)
- counter=counter+multi:len()
- end
- yield=yield+1
- if yield > 60 then
- os.sleep(.05)
- yield=0
- end
- end
- tape.seek(-size-9999)
- term.setCursorPos(1,3)
- term.write("Writing: "..counter.."/"..size.." ")
- print("-DONE-")
- request.close()
- else
- printError(err)
- end
- else
- printError(err)
- end
- else
- printError("Place a tape into the Tape Drive's tray plz")
- end
- else
- printError("Attatch a Tape Drive to this computer plz")
- end
- else
- printError("Plz add a direct file URL as an argument")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement