Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if tArgs[1] == "wyslij" then
- rednet.open("top")
- print("Oczekiwanie na drugi komputer!")
- print("Wpisz na nim 'pliki odbierz " .. os.computerID() .. "'")
- wait = true
- id = -1
- while wait do
- id2, msg = rednet.receive()
- if msg == "GET_FILE" then
- wait = false
- id = id2
- end
- end
- print("Polaczono!")
- rednet.send(id, tArgs[2])
- print("Wyslano nazwe pliku: " .. tArgs[2])
- plik = fs.open(tArgs[2], "r")
- dane = plik.readAll()
- rednet.send(id, dane)
- plik.close()
- print("Gotowe!")
- elseif tArgs[1] == "odbierz" then
- rednet.open("top")
- print("Laczenie...")
- rednet.send(0+tArgs[2], "GET_FILE")
- id, msg = rednet.receive(5)
- if msg == nil then
- print("Nie ma polaczenia!")
- return
- end
- plik = fs.open(msg, "w")
- print("Odbieranie pliku " .. msg)
- idd, dane = rednet.receive()
- print("Zapisywanie danych")
- plik.write(dane)
- plik.close()
- print("Zakonczono")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement