SHOW:
|
|
- or go back to the newest paste.
| 1 | local args = {...}
| |
| 2 | if not args[1] then | |
| 3 | error('Please specify a file!')
| |
| 4 | end | |
| 5 | if not fs.exists(args[1]) then | |
| 6 | error('File not found!')
| |
| 7 | end | |
| 8 | if not args[2] then | |
| 9 | error('Specify a modem!')
| |
| 10 | end | |
| 11 | if not peripheral.wrap(args[2]) then | |
| 12 | error('Modem not found!')
| |
| 13 | - | else |
| 13 | + | |
| 14 | - | local file = fs.open(args[1]) |
| 14 | + | |
| 15 | error('Peripheral is not a modem!')
| |
| 16 | - | rednet.send(19,file.readAll(),'print') |
| 16 | + | |
| 17 | local contents = {}
| |
| 18 | - | file.close() |
| 18 | + | local file = fs.open(args[1],'r') |
| 19 | - | end |
| 19 | + | repeat |
| 20 | local line = file.readLine() | |
| 21 | if line then | |
| 22 | table.insert(contents,line) | |
| 23 | end | |
| 24 | until not line | |
| 25 | rednet.open(args[2]) | |
| 26 | rednet.send(19,contents,'print') | |
| 27 | rednet.close(args[2]) | |
| 28 | file.close() |