lua-users home
lua-l archive

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



On Jul 11, 2006, at 15:31, Raymond Jacobs wrote:

Had no idea of the library thing, quite handy.

You can also achieve the same effect when loading your script in the first place:

local aSource = "function onClick() return true end"
local aChunk = loadstring( aSource )
local anEnvironment = {}

setmetatable( anEnvironment, { __index = _G } )
setfenv( aChunk, anEnvironment )

aChunk()

for aKey, aValue in pairs( anEnvironment ) do
        print( aKey, aValue )
end

> onClick function: 0x103ea0