lua-users home
lua-l archive

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


Put in your test.h

#ifdef __cplusplus
extern "C" {
#endif
void my_func(int blah);
#ifdef __cplusplus
}
#endif



And for calling to a globals functions that being loaded from your
scripts use some like this

by example in lua have

function OnInitialUpdate(str)
    print("Hello",str);
   
end

Call it from C
 
    lua_getglobal(L,"OnInitialUpdate");
    if(lua_type(L,-1) == LUA_TFUNCTION)
    {
       lua_pushstring(L,"Function Argument");      //OnInitial update
have 1 argument
       lua_call(L,1,0);   //Call function with 1 argument and not expect
any result
    }else
       lua_pop(L,1);   //pop any other type , by example nil if
OnInitialUpdate non exist;

And of course read PIL

Sorry by any errors , and poor english too.