Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function odbieraj()
- while true do
- id, msg = rednet.receive()
- print(id .. "> " .. msg)
- if msg == "/ping" then
- rednet.send(id, "/pong")
- print(os.getComputerID() .. "> /pong")
- print("**> " .. id .. " podlaczony!")
- end
- end
- end
- function wysylaj()
- while true do
- input = read()
- rednet.broadcast(input)
- if input == "/exit" then
- return
- end
- end
- end
- print("Witaj na Chacie!")
- rednet.open("top")
- print("Wpisz /exit aby wyjsc")
- rednet.broadcast("/ping")
- write("Podlaczeni: " .. os.getComputerID())
- while true do
- id, msg = rednet.receive(1)
- if msg == nil then
- print(".")
- break
- end
- if msg == "/pong" then
- write(", " .. id)
- end
- end
- parallel.waitForAny(odbieraj, wysylaj)
- print("Do zobaczenia")
Advertisement
Add Comment
Please, Sign In to add comment