Gert
2009-12-11 20:26:24 UTC
Hello,
Is there a way for dynamically loaded code to access local variables within a
function ? What I'm trying to do basically looks like this:
------------------------------------------------------------
var1 = "Hello"
local function one()
local var2 = "world"
local code = "print(var1, var2)"
chunk = loadstring(code)
chunk()
end
one()
------------------------------------------------------------
Since 'var2' is a local variable, the loadstring() chunk will not be able
to access it.
Thanks,
Is there a way for dynamically loaded code to access local variables within a
function ? What I'm trying to do basically looks like this:
------------------------------------------------------------
var1 = "Hello"
local function one()
local var2 = "world"
local code = "print(var1, var2)"
chunk = loadstring(code)
chunk()
end
one()
------------------------------------------------------------
Since 'var2' is a local variable, the loadstring() chunk will not be able
to access it.
Thanks,