Lua Loops

A numeric for runs from a start value to an end value, both inclusive: for i = 1, 3 visits 1, 2, and 3. The loop variable is local to the loop.

Lua
for i = 1, 3 do
  print(i)
end

local n = 5
while n > 2 do
  n = n - 2
end
print(n)
Read the full lesson