lua-users home
lua-l archive

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


example for lua_call in lua-manual.html :
Lua code: 
     a = f("how", t.x, 14)
C:
     lua_getfield(L, LUA_GLOBALSINDEX, "f");          /* function to be called */
     lua_pushstring(L, "how");                                 /* 1st argument */
     lua_getfield(L, LUA_GLOBALSINDEX, "t");            /* table to be indexed */
     lua_getfield(L, -1, "x");                 /* push result of t.x (2nd arg) */
     lua_remove(L, -2);                           /* remove 't' from the stack */
     lua_pushinteger(L, 14);                                   /* 3rd argument */

     lua_call(L, 3, 1);         /* call function with 3 arguments and1 result */
     lua_setfield(L, LUA_GLOBALSINDEX, "a");        /* set global variable 'a' */
----->
     lua_call(L, 3, LUA_MULTRET);
     // how to get count of result?