Posted 20 May 2012 - 10:41 AM
Hi
I'm trying to create chat program with a client and a server.
I need help figuring out how to check for incoming messages and be able to write a message at the same time.
When I do rednet.receive() it wont let me write something that I could send to the server.
Here is the code:
Client
Server
I'm trying to create chat program with a client and a server.
I need help figuring out how to check for incoming messages and be able to write a message at the same time.
When I do rednet.receive() it wont let me write something that I could send to the server.
Here is the code:
Client
rednet.open("right")
rednet.receive()
read()
function send(msg)
rednet.broadcast(msg)
end
function read()
while true do
message = io.read()
send(message)
end
end
Server
rednet.open("right")
print("Server online")
rednet.broadcast("Connect to server with ID #2")
rednet.receive()
read()
function send(msg)
rednet.broadcast(msg)
end
function read()
while true do
message = io.read()
send(message)
end
end