lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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,