Code: Select all
myvar = {}
myvar.var = 10
function myvar.func()
debugprint(myvar.var)
endfunction
Code: Select all
Function Func()
func.var=10
debugprint(func.var)
Endfunction
Code: Select all
myvar = {}
myvar.var = 10
function myvar.func()
debugprint(myvar.var)
endfunction
Code: Select all
Function Func()
func.var=10
debugprint(func.var)
Endfunction
Code: Select all
var = {}
var.x = 1
FUNCTION var.func()
ENDFUNCTION
Code: Select all
FUNCTION animation()
Timer = Timer + Timepassed
If Timer = 1 then...
If Timer = 2 then...
If Timer > 3 then Timer = 0
ENDFUNCTION
Code: Select all
myvar = {}
myvar.timer = 0
FUNCTION myvar.func()
myvar.timer = myvar.timer + timepassed
ENDFUNCTION
Code: Select all
Static Timer = Timer + Timepassed
Code: Select all
p_myvar = Function(...) Local pars = arg.n Return({pars[0],pars[...],pars[n]}) EndFunction
result1 = p_myvar(5, 2)
result2 = p_myvar(8)
result3 = p_myvar(5, 2, 4)
Code: Select all
p_myvar = Function(...) Return(Unpack(arg)) EndFunction
Of course I don't know much about the way Hollywood generates Lua code, but that shouldn't be a problem. Such a "Local Static varname" only needed to be translated into a global variable that is only used in this function. For me the question is more whether this would be an improvement for Hollywood.
Code: Select all
Function myfunc()
If IsNil(myvar) Then myvar=5
myvar=myvar+1
DebugPrint(myvar)
EndFunction
For i=1 To 3
myfunc()
Next