How can I get a size of a Lua table in C?
static int lstage_build_polling_table (lua_State * L) {
lua_settop(L, 1);
luaL_checktype(L, 1, LUA_TTABLE);
lua_objlen(L,1);
int len = lua_tointeger(L,1);
printf("%d\n",len);
...
}
My Lua Code:
local stages = {}
stages[1] = stage1
stages[2] = stage2
stages[3] = stage3
lstage.buildpollingtable(stages)
It´s printing 0 always. What am I doing wrong?