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:
[lua]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[/lua]
which doesn’t actually reset the loop.
Is there any way to do this in lua? [import]uid: 69531 topic_id: 12784 reply_id: 312784[/import]
Just put it all inside a function
[code]
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()
[/code] [import]uid: 24111 topic_id: 12784 reply_id: 46848[/import]
why so serious?
c [import]uid: 24 topic_id: 12784 reply_id: 46858[/import]
Cause I can
[import]uid: 24111 topic_id: 12784 reply_id: 46860[/import]