[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Global variables, local functions?
- From: PA <petite.abeille@...>
- Date: Tue, 11 Jul 2006 16:13:32 +0200
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