Filling a table randomly with a predetermined non sequential set of numbers


The concept : Make a temporary copy of your list, pull a number at random from it and place it from the table. Remove the number from the temporary list, pick another one and keep going until the temporary list is empty. That will effectively create a table like the one you described.

An even smarter way would be to place a copy of your list in the table and everytime you need a value from i you would pick a random one and remove it. Once the table has been depleted re-copy the list over to it and keep going.


[lua]for i=1, 60 do
local rand = math.random(1, #startTable)
table.insert(endTable, startTable[rand])
table.remove(startTable, rand)

You were using table.Random to get a random value from the start table and then trying to index the start table with that value.

I wish you had been sooner. I’ve been staring at this for awhile now and only just realized that what was going on. Thanks anyway though. And thank you too Crazy Quebec You have helped me avoid an issue I didn’t see coming.[URL=“”]