[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: loadstring and accessing local variables
- From: Gert <lua@...>
- Date: Fri, 11 Dec 2009 21:46:07 +0100
* On 2009-12-11 Petite Abeille <email@example.com> wrote :
> On Dec 11, 2009, at 9:26 PM, Gert wrote:
> > Is there a way for dynamically loaded code to access local variables
> > within a function ?
> Alternatively, take a look at setfenv.
> Setting the environment of the loaded chunk before executing it would
> most likely allow you to achieve what you are after.
I've been playing around with that but no luck yet.
my first try was
But this fails. My guess would be that getfenv() would get the
environment for the current function, but the environment does not
contain the local variables of the function itself, only the functions
in, well, it's environment.