lua-users home
lua-l archive

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

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

-----Original Message-----
[] On Behalf Of Daniel Silverstone
Sent: Tuesday, December 18, 2007 1:39 AM
Subject: Re: Call module function from C

On Tue, 2007-12-18 at 01:31 -0800, Tony Paloma wrote:

First up, instead of:

> lua_getglobal(GetLuaState(), "hook.Call");


lua_getglobal(GetLuaState(), "hook");
lua_pushliteral(GetLuaState(), "Call");
lua_gettable(GetLuaState(), -2);
lua_remove(GetLuaState(), -2);

Also, I'd be tempted to stuff a lua_State *L = GetLuaState() at the top,
unless GetLuaState is a correctly consted function such that the
compiler can optimise away calls to it.


Daniel Silverstone               
PGP mail accepted and encouraged.            Key Id: 2BC8 4016 2068 7895