Posted 13 December 2013 - 05:54 PM
So I have computers located around my central computer and I want them all to broadcast their ID numbers to the central computer which is supposed to choose one at random and send it a message. So far I can get the IDs to be stored in a table and I can choose an entry at random, but when it displays the chosen ID it displays it like this {["id"]=17}
The error I get is:
So how would I be able to pull out only the ID number?
Here's my code:
Thanks in advance for any help :D/>
The error I get is:
rednet:39: Expected number
because the variable A isn't a numberSo how would I be able to pull out only the ID number?
Here's my code:
rednet.open("back")
IDs = {}
print("How many computers would you like to use?")
X = tonumber(read())
rednet.broadcast(os.computerID())
for a=1 X do
cID, cMsg, cDis = rednet.receive()
table.insert(IDs, {id=cID})
end
A = textutils.serialize(IDs[math.random(1, X)])
print(A)
rednet.send(A, "Go", true)
Thanks in advance for any help :D/>