Can somebody explain this?

Hey! I know these can be used for round based systems and other things. However, I don’t understands the numbers like what does each number do? This is something I can’t grasp on. Thank you!

For i = 10, 20, 30 do

end
1 Like

Set up this way this is a for next loop. It would start at 10 and end at 20 … the 30 is far to large of a step in this case as it wouldn’t be possible to step by 30.

For i = 10, 20, 1 do

end

Would work fine. Starts at 10 ends at 20 with a step of 1. Each time this loops the i moves 1 step.
So … i, would equal 10, 11 ,12 till 20.

This may help more … intro-to-for-loops

2 Likes

i = number means where it starts
20 = end
30 = step
i think yea (i forget easily when i dont program it just comes back to me instantly yeah but what post above said)

2 Likes

Okay so the first to numbers are start and ends. The last number is steps?

1 Like

yes, that is what it means i have to write all of this to exceed the limit

1 Like

Yeah, I don’t like the word limit. Seems simple enough to remember.

So let’s say if I want to know if the round ended. Do I do this?

if i == 0 then

end
1 Like

It depends how you have the for loop set up. If it starts high and decrements until it reaches 0, then the loop will just end and continue with the code after and you won’t have to do that.

1 Like

Shouldn’t you use a while loop instead?

I assume they mean for a timer system, although I am guessing since for loops aren’t a great way to make timers.

1 Like

this explains it pretty well:

image

1 Like

Thanks for your guys support! I’ll try to use this type of loops in my games.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.