This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Reverse for i loop
#1
Hello,

I'm trying to figure out a way to reverse a loop counting backwards instead.
This code work for normal loop

Code:
12345678
local strStart = 1 local strStop = 5 local result = 0 for i = strStart, strStop do   result = result + 1   log(result, i) end

But running something like this, renders nothing.
Code:
12345678
local strStart = 5 local strStop = 1 local result = 5 for i = strStart, strStop do   result = result - 1   log(result, i) end

Is it possible to do a reverse loop with simple code?
Reply
#2
Use this:
Code:
123
for i = 5, 1, -1 do ... end
Reply


Forum Jump: