I want to loop a function, but not infinitely. Let's say I wanted to do it 5 times.
function spawnmob()
end
spawnmob()
spawnmob()
spawnmob() -- not what i want to do
spawnmob()
spawnmob()
Is there a way to loop functions X number of times?
I want to loop a function, but not infinitely. Let's say I wanted to do it 5 times.
function spawnmob()
end
spawnmob()
spawnmob()
spawnmob() -- not what i want to do
spawnmob()
spawnmob()
Is there a way to loop functions X number of times?
Use a return statement :)
local o = 0
return
o = o + 1
spawnmob()
wait (1) ---Replace with number of seconds within each spawn (IMPORTANT)
until o = 5 ----Replace 5 with whatever
Best of Luck
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
Thanks.
Actually, have a problem with that. See, I'm using it in a function. The function is fired by a loop that checks for something. It doesn't work in a function.
Fixed it myself using wiki. Still thanks, this led me to the wiki.
@better or use a for loop since that's what for loops are for