SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local component = require "component" |
| 1 | + | local component = require "component" |
| 2 | - | local args = {...} |
| 2 | + | local args = {...}
|
| 3 | - | |
| 3 | + | |
| 4 | - | local firstAddr,restOfPath,returnPath,name,user,filename = args[1],args[2],args[3],args[4],args[5],args[6] |
| 4 | + | local firstAddr,restOfPath,returnPath,name,user,filename = args[1],args[2],args[3],args[4],args[5],args[6] |
| 5 | - | |
| 5 | + | |
| 6 | - | print("Filename: "..filename) |
| 6 | + | print("Filename: "..filename)
|
| 7 | - | local modem = component.modem |
| 7 | + | local modem = component.modem |
| 8 | - | |
| 8 | + | |
| 9 | - | local f = io.open(filename,"rb") |
| 9 | + | local f = io.open(filename,"rb") |
| 10 | - | print "File opened" |
| 10 | + | print "File opened" |
| 11 | - | local c = f:read("*a") |
| 11 | + | local c = f:read("*a")
|
| 12 | - | print "File read." |
| 12 | + | print "File read." |
| 13 | - | f:close() |
| 13 | + | f:close() |
| 14 | - | local ct={} |
| 14 | + | local ct={}
|
| 15 | - | repeat |
| 15 | + | repeat |
| 16 | - | table.insert(ct,c:sub(1,4095)) |
| 16 | + | table.insert(ct,c:sub(1,4095)) |
| 17 | - | c=c:sub(4096) |
| 17 | + | c=c:sub(4096) |
| 18 | - | print("Chunk "..#ct.." separated") |
| 18 | + | print("Chunk "..#ct.." separated")
|
| 19 | - | until c=="" |
| 19 | + | until c=="" |
| 20 | - | |
| 20 | + | |
| 21 | - | print "Beginning sending" |
| 21 | + | print "Beginning sending" |
| 22 | - | for k,v in pairs(ct) do |
| 22 | + | for k,v in pairs(ct) do |
| 23 | - | print("Part "..k) |
| 23 | + | print("Part "..k)
|
| 24 | - | modem.broadcast(42,firstAddr,restOfPath,returnPath,name,user,v) |
| 24 | + | modem.broadcast(42,firstAddr,restOfPath,returnPath,name,user,v) |
| 25 | end |