Advertisement
nagoL2015

Tape Write

Apr 8th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. tape = peripheral.find("tape_drive")
  2. data = 1
  3. h = http.get("https://my.mixtape.moe/ztnkpu.dfpwm", nil, true)
  4.  
  5. local blockSize = 8192 -- how many bytes to read at a time
  6.  
  7. tape.stop()
  8. tape.seek(-tape.getSize())
  9.  
  10. repeat
  11.     local bytes = {}
  12.    
  13.     for i = 1, blockSize do -- only read 8192 bytes at a time
  14.         local byte = h.read()
  15.         if not byte then break end -- if we're done, stop reading
  16.         bytes[#bytes + 1] = byte -- add the byte to bytes    
  17.     end
  18.    
  19.     if #bytes > 0 then
  20.         print("Still going... " .. os.epoch())
  21.        
  22.         for i = 1, #bytes do
  23.             tape.write(bytes[i])    
  24.         end
  25.        
  26.         sleep(0)
  27.     end
  28. until not bytes or #bytes <= 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement