Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ping()
- rednet.open("back")
- rednet.broadcast("PINGchat","kdchat")
- end
- function pong()
- rednet.open("back")
- senderId, message, protocol = rednet.receive()
- if message == "PINGchat" then
- rednet.send(senderId,"PONGchat",protocol)
- setupChat()
- else
- pong()
- end
- end
- function setupChat()
- if term.isColor() then
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- return "color"
- else
- return "no color"
- end
- end
- function writingChat()
- while true do
- msg = io.read()
- if msg == "/exit" then
- error("User exited program!")
- else
- print(user..": "..msg)
- rednet.send(senderId,msg,protocol)
- end
- end
- end
- function receivingChat()
- while true do
- rednet.receive(protocol)
- end
- end
- function coroutineController()
- chatIn = coroutine.create(receivingChat())
- coroutine.resume(chatIn)
- end
- ping()
- pong()
- ping()
- coroutineController()
- writingChat()
Add Comment
Please, Sign In to add comment