CCHacker132

M_Print_Program

Dec 29th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. end
  14. if peripheral.getType(args[2]) ~= 'modem' then
  15.     error('Peripheral is not a modem!')
  16. end
  17.     local contents = {}
  18.     local file = fs.open(args[1],'r')
  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()
Add Comment
Please, Sign In to add comment