lua-users home
lua-l archive

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

Change the "setTimer(5.0, onTimer)" to be "setTimer(5.0, "onTimer")" then
you can load the function via lua_getglobal()

Charles Curley, Dynacs, Kennedy Space Center, Florida, 321-867-6399

-----Original Message-----
From: "Björklund, Peter" []
Sent: Tuesday, September 04, 2001 5:56 AM
To: Multiple recipients of list
Subject: Get the function value

How do I get the function value from the stack?

Sample Lua code:

function onTimer()

function onInit()
        -- This is a C function
        setTimer( 5.0, onTimer );

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 :)

        g_functionName = // How do I get this parameter?

        return 0;

Please help me out!