[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Get the function value
- From: "Eric Ries" <eries@...>
- Date: Tue, 4 Sep 2001 09:26:07 -0700
Take a look at lua_ref in the Lua 4.0 manual.
Eric
> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Björklund, Peter
> Sent: Tuesday, September 04, 2001 9:12 AM
> To: Multiple recipients of list
> Subject: RE: Get the function value
>
>
> 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....
>
> ------------------------