lua-users home
lua-l archive

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


I'm trying to get the return values from a lua function from C. But I'm
missing something

// Here's the LUA
function Test()

	return "One", "Two", "Three"

end


// Here's the C

	...
    int start_index = lua_gettop( spGlobalState );


    lua_pushstring( spGlobalState, "loadstring" );      // function name
    lua_gettable( spGlobalState, LUA_GLOBALSINDEX );    // function to be
called
    lua_pushstring( spGlobalState, command.c_str() );   // parameter
    lua_call( spGlobalState, 1, 1 );                    // call function
with 1 arguments and 1 result
    lua_call( spGlobalState, 0, LUA_MULTRET );          // call function
with 0 arguments and variable results

    int end_index = lua_gettop( spGlobalState );
	...

I'm expecting end_index - start_index to be 3 since Test() returns 3 values,
but it's allways zero.

I'm sure I'm missing something simple...

Any help?

Thanks,
Kevin