Advertisement
JackMacWindows

tapeurl.lua

Sep 10th, 2022 (edited)
1,515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. local handle = assert(http.get(..., nil, true))
  2. local tape = assert(peripheral.find("tape_drive"), "No tape drive found")
  3. tape.stop()
  4. tape.seek(-tape.getSize())
  5. tape.stop()
  6. if handle.getResponseHeaders()["Content-Length"] then print("Total size: " .. handle.getResponseHeaders()["Content-Length"]) end
  7. local y = select(2, term.getCursorPos())
  8. local n = 0
  9. repeat
  10.     local data = handle.read(4096)
  11.     if data then tape.write(data) n = n + #data end
  12.     write(n)
  13.     term.setCursorPos(1, y)
  14. until not data or #data < 4096
  15. handle.close()
  16. print("Wrote tape")
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement