Decreasing "for" loop

I’m somewhat experienced in a couple other languages such as java and c++ and was wondering if the for loop has to count up or if it can only count down

For example in java I would enter:

for (i=20, i>0, i--) {
  print(i);
}

And it will countdown from 20 to 0, is there anything like that in lua or will I just need to learn how to do it with a while loop?

Thanks in advance.

for I=20,0,-1 do

end

It’s done like in good (?) old (definitely) C64 BASIC, just without mentioning “STEP”.


for i = 20, 0, -1 do
    -- do something with i
end

For more guidance:

http://www.lua.org/pil/4.3.4.html

Besides, I hope you don’t have to “learn” how to use while as a replacement for for.

Or, instead of using I directly, use K and define K as negative I.