Hi!
I tried to write some data into lua and read it out in code. But it looks like the lua code doesn't support recursion.
Here's my example:
function TestForEach(v, n)
local sum = 0;
if n > 0 then
sum = v + TestForEach(v, n-1);
end
return sum;
end
print(TestForEach(3, 3));
It should be 9 but it's 0.
plugin version: 2.2.1
What can i do?
Lua Code cannot be recursive
Re: Lua Code cannot be recursive
It looks like there might be an issue with locals in this Lua implementation. I'll check that for the next release (v2.2.5). In the meantime, you can just change it to this:
Code: Select all
function TestForEach(v, n)
if n > 0 then
return v + TestForEach(v, n-1)
end
return 0
end