[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Get the function value
- From: RLake@...
- Date: Tue, 4 Sep 2001 11:09:07 -0500
You don't get the function name, you get the function. You can then call
it; see below
> How do I get the function value from the stack?
-----------------------------------
Sample Lua code:
function onTimer()
doStuff();
end
function onInit()
-- This is a C function
setTimer( 5.0, onTimer );
end
----------------------------------
C code:
static int setTimer(lua_State *L)
{
if ( lua_isnumber( L, 1 ) )
g_waitTime = lua_tonumber( L, 1 );
// lua_typename( L, lua_type( L, 2 ) )
// returns "function" which is what I want :)
/// here is a simple way of doing it
lua_settop(L, 2); /* make sure there's no more on the
stack */
lua_rawcall(L, 0, 0); /* no arguments, no return values */
///
/* who cares what the name is?
g_functionName = // How do I get this parameter?
*/
return 0;
}
-----------------------
This message sent privately....
------------------------