Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you do this after a certain number of loops?

Asked by
Zerio920 285 Moderation Voter
10 years ago

Say I had a "for" loop that repeated 10 times, but after 3 loops I'd want something else to occur without changing what happens in the loop. How would I do this?

1 answer

Log in to vote
1
Answered by 10 years ago

You assign an index value to your loop. When the index value hits three, you execute the code:

for i = 1,10 do
    -- regular
    if i == 3 then
        -- special code
    end
end
Ad

Answer this question