Posted 08 December 2012 - 10:39 PM
This is a little tutorial to send multiples messages in one message with rednet.
First, use string.gmatch at the receiver to separate the messages like this:
You will fond more information about the "%s+" (line 3) here.
Next, use normal rednet sender at the sender:
Have fun!
(sorry for my bad english)
First, use string.gmatch at the receiver to separate the messages like this:
senderId, message, distance = rednet.receive() -- Wait for a message
multiMessages = { } -- Declare a table. It will contains the messages
for w in string.gmatch(message, "%s+") do -- Separate the messages
multiMessages[#multiMessages + 1] = w -- Add all messages in the table
end
You will fond more information about the "%s+" (line 3) here.
Next, use normal rednet sender at the sender:
print "First message to send?"
message1 = read() -- Input
print "Second message to send?"
message2 = read() -- Input
print "Id of the computer?"
sId = read() -- Input
id = tonumber(sId) -- Convert string to a number
rednet.send(id, message1 .. " " .. message2) -- Send messages
Have fun!
(sorry for my bad english)