[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: loadstring and accessing local variables
- From: Gert <lua@...>
- Date: Fri, 11 Dec 2009 21:26:24 +0100
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,