Excellent method!
Heres a little demo for the people with unity
do
var_inc()
loop
function var_inc()
set_static_int("var1",get_static_int("var1")+1)
print str$(get_static_int("var1"))
endfunction
function set_static_int(name$,value)
lua set int name$,value
endfunction
function get_static_int(name$)
v = lua get int(name$)
endfunction v
By the way, is there any speed loss with ths compared to a global or a variable that would be in a dll?
if there is it's probably neglegible except for crucial functions though I think.
The only problem I can see in this method is that the variables inside are not private(or are they?), so you could not for instance have a variable like playerhealth in one function and have another playerhealth in a second function and have them unique from each other.