Lua Code cannot be recursive
Posted: Sun Jan 05, 2020 5:52 am
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?
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?