[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Setting 'outer' globals from within nested fenvs?
- From: Mark Sibly <blitzman@...>
- Date: Sun, 18 Nov 2007 11:28:06 +1300
Lua newbie here...
I've just got the hang of using __index to access variables declared in
an 'outer' scope/table, but I can't work out how to modify them.
Instead, a new 'inner' variable always gets created.
Is there any way to do this?
Ideally, if I've got code like...
...and HitPoints exists in an 'outer' environment, the outer version
should be modified. If there is no outer version, a new HitPoints
should be created in the inner env. Currently, using __index allows the
code to 'read' the outer HitPoints, but not write it.
Sorry for the lack of sample code, but it's a c/lua hybrid thingy,
where c code sets up a new inner env using fsetenv, chaining it to an
outer env using __index. I have a feeling I'll be able to do a lot of
the C stuff in Lua eventually once I get bit more pratice though!