lua-users home
lua-l archive

RE: Get the function value

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


Interesting code.
But what I want to do is keep the value, so I can issue a lua_call() later
on.
/Peter
-----Original Message-----
From: RLake@oxfam.org.uk [mailto:RLake@oxfam.org.uk]
Sent: den 4 september 2001 18:09
To: Multiple recipients of list
Subject: Re: Get the function value
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....
------------------------

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