[Change] Fixed space.faction to allow to check easily for certain factions.
This commit is contained in:
parent
9c6567195c
commit
413ced137d
@ -308,9 +308,9 @@ static int space_faction(lua_State* L) {
|
|||||||
/* Return the result in table. */
|
/* Return the result in table. */
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
for(i = 0; i < s->nplanets; i++) {
|
for(i = 0; i < s->nplanets; i++) {
|
||||||
lua_pushnumber(L, i+1); /* Index. */
|
lua_pushboolean(L, 1); /* Value. */
|
||||||
lua_pushstring(L, faction_name(s->planets[i].faction)); /* Value. */
|
lua_setfield(L, -2, faction_name(s->planets[i].faction)); /* Key. */
|
||||||
lua_rawset(L, -3); /* Store in table. */
|
/* Allows syntax foo = space.faction("foo"); if foo["bar"] then ... end */
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user