[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: How do I add a "local" using the c api
- From: "Tom Miles" <Tom@...>
- Date: Tue, 31 Mar 2009 14:22:53 +0100
I don't know if this has been discussed before, I had a quick look at
the list archives, but only found something a bit relevant that didn't
seem to amount to anything.
My question is this though. I have several states that inherit their
environment from parent states. When I initiate a state I call some c
code to add some extra standard bits and pieces, some of which I want
child states to inherit, others I don't. In a script I would declare
these as local, but I haven't found anything that copies the required
behaviour in the c api. I've found lua_setlocal(), but that's part of
the debug library, so would seem inappropriate, and the only reference I
found on the list before mentions upvalues. Are local variables just
upvalues for the entire state or something?
In short, how do I achieve something like this from the c api when I
create my state?
-- script start
local MAX_LIMIT = 10
-- lots of functions that use MAX_LIMIT everywhere
-- end script
(Short script huh!)
Thanks for any help,