lua-users home
lua-l archive

Re: Testing for the presence of lua functions from C

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


bwalmisley@btinternet.com wrote:
>
> So when "fredname" is destroyed something like:
> 
> if( lua_isFunctionPresent("fredname_IsDestroyed")
> {
> lua_fn = lua_getglobal("fredname_IsDestroyed");
> lua_callfunction(lua_fn);
> }
lua_getglobal(L, "fredname_IsDestroyed");	// you get nil if undefined
if (lua_type(L, -1) != LUA_TNIL)		// or: ... == LUA_TFUNCTION
 lua_call(L, 0, 0);
else
 lua_pop(L, 1);
Ciao, ET.

AltStyle によって変換されたページ (->オリジナル) /