Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sides={"top","bottom","back","front","left","right"}
- for i=1,6 do if peripheral.getType(sides[i]) == "modem" then rednet.open(sides[i]) end end
- message="talk1"
- function send()
- rednet.broadcast(io.read())
- end
- function recieve()
- e,modemSide,channel,id,modemMessage =os.pullEvent()
- if e=="modem_message" then
- if modemMessage.sProtocol == "string" then
- if modemMessage.message == "getComputers" then
- rednet.send(id,os.getComputerID(),"number")
- end
- end
- end
- end
- function getComputers()
- computerIds={}
- e=""
- os.startTimer(1)
- rednet.broadcast("getComputers","string")
- while e~="timer" do
- e,modemSide,channel,id,modemMessage =os.pullEvent()
- if e=="modem_message" then
- computerIds[#computerIds+1]=id
- end
- end
- return computerIds
- end
- function host()
- while true do
- recieve()
- end
- end
- host()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement