diff --git a/src/llua.c b/src/llua.c index 005e22c..5686645 100644 --- a/src/llua.c +++ b/src/llua.c @@ -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; }