Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = { ... }
- local tape = peripheral.find("tape_drive")
- local function writeTape(url)
- local file
- local bytery = 0
- tape.stop()
- tape.seek(-tape.getPosition()) --Rewind to start
- tape.stop() --Just making sure
- tape.stop()
- tape.seek(-tape.getPosition()) --Rewind to start
- tape.stop() --Just making sure
- print("Writing...")
- file = http.get(url, nil, true) -- THIS IS IMPORTANT
- -- tape.write(response.readAll())
- -- file = http.get(url)
- --
- repeat
- local bytes = {}
- for i = 1, (8192) do
- local byte = file.read()
- if not byte then break end
- byte = bit.band(255, byte)
- bytes[#bytes + 1] = byte
- end
- for i = 1, #bytes do
- tape.write(bytes[i])
- end
- bytery = bytery + #bytes
- print("Read " .. bytery .. " bytes...\n")
- sleep(0)
- until not bytes or #bytes <= 0
- print("Removing trailing garbage...")
- for k = 1, 128 do
- for i = 1, 8192 do
- tape.write(0)
- end
- end
- file.close()
- tape.stop()
- tape.seek(-tape.getPosition()) --Rewind to start
- tape.stop() --Just making sure
- print("\nDone.")
- end
- writeTape(args[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement