How would I be able to run a numeric for loop through a range?

Say, take, a number for loop, such as this:

for i = 1, 10 do
   --code
end

I understand that this would make i increment from 1 to 10. What I don’t know is how I could run this from a range instead. For example, instead of just going from 1 to 10, it starts at 2, then it goes to 10.

So my question is: How would I be able to use a numeric for loop to run through a range of numbers, instead of just from 1 to whatever the second value is?

Change the 1 to a 2. The first number is the starting number and the second is the end point. You can also add an optional third number which is the increment amount.

1 Like
for i = 2, 10 do
    print(i)
end
2 Likes

Damn, I’m stupid. I thought the first number was for the increment you were going by, guess I was wrong.

1 Like

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