[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Call module function from C
- From: "Duncan Cross" <duncan.cross@...>
- Date: Tue, 18 Dec 2007 11:33:54 +0000
On Dec 18, 2007 9:45 AM, Tony Paloma <email@example.com> wrote:
> Thank you, this worked. Also, GetLuaState() is inlined so declaring it at
> the top would make no difference.
> I'm not very good with Lua's C interface so perhaps you could help me
> understand this. The first line you gave me is pretty self explanatory, but
> what is pushliteral doing? And then why do we get and remove the 2nd item on
lua_pushliteral is putting "Call" onto the stack, and lua_gettable is
replacing it with hook["Call"]. (lua_getfield does the same thing as
these two functions, but is (slightly) slower.) The second item on the
stack is the "hook" table, which is removed here since it's worth
getting into the habit of remove stuff you no longer need from the
stack, as it has a limited capacity.