Forum

> > CS2D > Scripts > How to iterate a table from C/C++
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch How to iterate a table from C/C++

2 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Re: How to iterate a table from C/C++

Flacko
User Off Offline

Zitieren
1
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)
}
Where YOURINDEX you should place the stack index of the table you're trying to iterate
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht