Advertisement
shadowkat1010

SKS-FTP

Dec 22nd, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. function connect()
  2. rednet.open("top")
  3. rednet.open("back")
  4. rednet.open("right")
  5. rednet.open("left")
  6. end
  7.  
  8. function disconnect()
  9. rednet.close("top")
  10. rednet.close("back")
  11. rednet.close("right")
  12. rednet.close("left")
  13. end
  14.  
  15. function receiveFile(path,inputid)
  16. local file = fs.open(path,"w")
  17. id, msg = rednet.receive()
  18. if id == inputid then
  19. file.write((msg))
  20. file.close()
  21. end
  22. end
  23.  
  24. function sendFile(path,inputid)
  25. local file = fs.open(path,"r")
  26. content = file.readAll()
  27. rednet.open("top")
  28. rednet.send(inputid,(content))
  29. file.close()
  30. end
  31.  
  32. tArgs = {...}
  33. if tArgs[1] == "send" then connect() sendFile(tArgs[2],tArgs[3]) disconnect()
  34. elseif tArgs[1] == "receive" then connect() receiveFile(tArgs[2],tArgs[3]) disconnect()
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement