the problem with the 6 loop method is that one computer could send twice in the time and one computer would be forgotten.
Is the main computer always going to receive messages from the same 6 computers ?
if it is then we can set up our main computer to receive messages from those 6 computers only.
rednet.open("back")
senders = { 2, 3, 4, 5, 6, 7 } -- our valid senders
recmess = {}
cmpmess = {}
loop = true
count = 1
while loop do
if count > 6 then loop = false break end
eventmess = {} -- clear table
eventmess = {os.pullEvent()} -- grab ospull as a table.
if eventmess[1] == "rednet_message" then
for i = 1,#senders do
if eventmess[2] == senders[i] and recmess[i] ~= true then
recmess[i] = true
cmpmess[count][1] = eventmess[3] -- set the message in value 1
cmpmess[count][2] = eventmess[2] -- set the cmputer id sending in value 2
count = count +1
end
end
end
end
That little bit of code will grab the event, check if the computer is valid and store the messages in a table… simply retreive the information from the table cmpmess[1][1] for the first computer to send. and cmpmess[6][1] for the last.
cmpmess[1][2] will give the computer ID that sent the message cmpmess[1][1] so you could sort which computer sent which message
due to the lack of sleep() commands this will grab and store as quickly as I could manage.
I wrote theprogram again but improoved it and made it print results
Spoiler
rednet.open("back")
senders = { 2, 3 } -- our valid senders
recmess = {}
cmpmess = {{};{}}
loop = true
count = 1
while loop do
-- os.startTimer(10)
if count > table.maxn(senders) then loop = false break end
eventmess = {} -- clear table
eventmess = {os.pullEvent()} -- grab ospull as a table.
if eventmess[1] == "rednet_message" then
for i = 1,#senders do
if eventmess[2] == senders[i] and recmess[i] ~= true then
recmess[i] = true
cmpmess[count][1] = eventmess[3]
cmpmess[count][2] = eventmess[2]
count = count +1
end
end
end
end
ordermess = {{};{}}
for i = 1,#cmpmess do -- count our cmpmessages event though we know it is 6.
for n = 1,#senders do -- check our senders
if senders[n] == cmpmess[i][2] then -- if our Sender matches we copy the information to the senders position in our sender table.
ordermess[n][2] = cmpmess[i][1] -- I think this should set the table to the entire table
ordermess[n][1] = cmpmess[i][2]
end
end
end
for i = 1,#senders do
print(ordermess[i][1])
print(ordermess[i][2])
end
Edit :: these code tags are not holding the indentations very well in BBcode. on the screen where i typed it… its all neat and tidy. posted and its a jumble of crap indents