How can I know the number of arguments passed to a C function from lua?
Will the following work?
int test(lua_State *l) {
int result = 0;
int n=1;
while(!lua_isnil(l,n)) {
result = result + lua_tointeger(l, n);
++n
}
lua_pushnumber(l, result);
return 1;
}
NOTE: This is essentially a resurrection of a question deleted by its owner that I thought was worth keeping.