lua-users home
lua-l archive

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


On Tue, 2004-04-13 at 03:00, Ryan Leigh wrote:
> Which is a pain and error prone (because I'm a lousy typist). So, to
> finally get to the point, is there something I can do where when I
> call a function that is in some object and I reference a variable, is
> there someway I can force it to look in the object's table first
> before going global? I guess this is similar to having a C++ class and
> I want to scope to member variables in a member function. Or am I just
> not envisioning all the possibilities of Lua and there exists a much
> better way of doing things.

Erm, it doesn't help the whole object-then-global thing (you'd need
metatables for that) but..

setfenv(myobject.update,myobject) might do what you want. (no guarantees
here, I can't remember the exact syntax or side-effects, read the docs
for more info)

D.

-- 
Daniel Silverstone                       http://www.digital-scurf.org/
Hostmaster, Webmaster, and Chief Code Wibbler: Digital-Scurf Unlimited
GPG Public key available from keyring.debian.org       KeyId: 20687895