Reset a for loop?

I have a for loop which is supposed to check a value against the value of every other value in a display group. If the values match the current one must generate a new value and then check itself against them all again. Now my problem is once I find a matching number how can I reset the loop so that it starts at the beginning again to check the new value against all children of the group. I tried doing this:

1
2
3
4
5
6
7
for i = 1, neutralGroup.numChildren do
        local child = neutralGroup[i]
        if(current.value == child.value) then
                current.value = math.random(1,96)
                i = 1
        end
end

Just put it all inside a function ;-)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function checkValue()
 
for i = 1, neutralGroup.numChildren do
        local child = neutralGroup[i]
        if(current.value == child.value) then
                current.value = math.random(1,96)
                i = 1
        end
end
 
end
 
--When you want to start the loop again simply just call the function:
 
checkValue()

why so serious?

c

Cause I can

:)

views:1382 update:2011/10/5 8:48:05
corona forums © 2003-2011