Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CLIENT_PORT = 0
- io.write("Set a server port: ")
- SERVER_PORT = tonumber(io.read())
- print("Server port has been set to: "..SERVER_PORT)
- local modem = peripheral.find("modem")
- modem.open(SERVER_PORT)
- if CLIENT_PORT == 0 then
- print("I am not broadcasting to anyone")
- end
- function pingLoc()
- io.write("Select robot to ping: ")
- local num1 = tonumber(io.read())
- modem.transmit(num1, num1, "pingLoc")
- end
- while true do
- event, modemSide, senderChannel, replyChannel, message, distance = os.pullEvent("modem_message")
- if message == "connectMessage" then
- print("Connection detected from "..replyChannel)
- modem.transmit(replyChannel, SERVER_PORT, "connectSuccess")
- end
- local command = io.read()
- if command == "Loc" then
- pingLoc()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement