[Change] Fixed space.faction to allow to check easily for certain factions.

This commit is contained in:
Allanis 2013-07-28 17:48:05 +01:00
parent 9c6567195c
commit 413ced137d

View File

@ -308,9 +308,9 @@ static int space_faction(lua_State* L) {
/* Return the result in table. */
lua_newtable(L);
for(i = 0; i < s->nplanets; i++) {
lua_pushnumber(L, i+1); /* Index. */
lua_pushstring(L, faction_name(s->planets[i].faction)); /* Value. */
lua_rawset(L, -3); /* Store in table. */
lua_pushboolean(L, 1); /* Value. */
lua_setfield(L, -2, faction_name(s->planets[i].faction)); /* Key. */
/* Allows syntax foo = space.faction("foo"); if foo["bar"] then ... end */
}
return 1;
}