math.random... Tables ..is it possible ?

Hi
Is it possible to pick up all positions from table this way ? One by one
Exmple..

1
2
3
4
5
numbers = {1,2,3,4,5,6,7,8,9,10}
 
for i =1 , #numbers do
random = numbers[math.random(1, #numbers)
end

You could implement some sort of shuffle then just run through it

1
2
3
4
5
6
7
local numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
 
numbers = ShuffleFunction(numbers)
 
for i = 1, #numbers do
    random = numbers[index]
end

mattthew maybe I did something wrong but the result is the same :)

I need to pick up ALL object from table one by one on random order.

matthew sorry I was wrong. Thank you math.random on table indexes is a good idea.

views:1346 update:2011/9/27 18:14:54
corona forums © 2003-2011