Posted 27 January 2013 - 01:08 PM
What code do I need for a computer to receive a message from another computer? I've tried several things but they all return errors.
-- Open the rednet modem. This assumes you have the modem on the top of the computer. You can change it to left, right, bottom, etc...
rednet.open("top")
-- Broadcast a message to all computers
print("Sending Message")
rednet.broadcast("Hello, World!")
-- Wait for a response from another computer
print("Waiting for response...")
id, message = rednet.receive()
print("We received a response from comptuer ID: " .. id)
print("With the message: " .. message)
-- Open the modem. Same as the first program
rednet.open("top")
-- Wait for a message
print("Waiting for a message")
id, message = rednet.receive()
print("Message received from comptuer ID: " .. id)
print("Message says: " .. message)
-- Send a response to the computer that just sent us a message
print("Sending response")
rednet.send(id, "Hello there! Received your message!")