I am calling a recursive function in Lua. The results I want are as follows.
0.016666666666667
wait
0.033333333333333
wait
0.05
wait
0.066666666666667
wait
result
However, the results are as follows.
0.016666666666667
0.033333333333333
0.05
0.066666666666667
result
wait
wait
wait
The code is as follows. I ask for your understanding first. I'm a beginner at Lua. And I looked for it a lot, but I couldn't get the answer I wanted. Can someone help me?
seconds = 0
user_wait = function()
seconds = seconds + (1/60)
print(seconds)
if seconds <= 3/60 then
user_wait()
print("wait")
else
seconds = 0
print("result")
return 1
end
end
user_wait()