edited 1×, last 26.01.11 01:45:23 am
Forum
Scripts
How to iterate a table from C/C++
How to iterate a table from C/C++
2 replies
1

1
2
3
4
5
6
7
2
3
4
5
6
7
lua_pushnil(L); //This will be the key
while(lua_next(L,YOURINDEX) !=0)
{
	int k = lua_tointeger(L,-2); //Get the key
	int v = lua_tointeger(L,-1); //Get the value
	lua_pop(L,1); //Pop v from the stack and keep k for the next iteration (as we did when we pushed nil)
}
1

Offline