|
> Does lua provide static variables? there might be a simpler way, but something like this should work: do local i=0 function foo() i=i+1 return i end end print(foo()) print(foo()) print(foo()) print(foo()) print(foo()) print(i) this should print 1 2 3 4 5 nil