/** * @brief Gets a outfit. * * @usage s = outfit.get( "Heavy Laser" ) -- Gets the heavy laser * * @luaparam s Name of the outfit to get. * @luareturn The outfit matching name or nil if error. * @luafunc get( s ) */ static int outfitL_get( lua_State *L ) { const char *name; Outfit *lo; /* Handle parameters. */ name = luaL_checkstring(L,1); /* Get outfit. */ lo = outfit_get( name ); if (lo == NULL) { NLUA_ERROR(L,"Outfit '%s' not found!", name); return 0; } /* Push. */ lua_pushoutfit(L, lo); return 1; }
/** * @brief Gets the outfits sold at a planet. * * @luatparam Planet p Planet to get outfits sold at. * @luatreturn {Outfit,...} An ordered table containing all the outfits sold (empty if none sold). * @luafunc outfitsSold( p ) */ static int planetL_outfitsSold( lua_State *L ) { Planet *p; int i, n; Outfit **o; /* Get result and tech. */ p = luaL_validplanet(L,1); o = tech_getOutfit( p->tech, &n ); /* Push results in a table. */ lua_newtable(L); for (i=0; i<n; i++) { lua_pushnumber(L,i+1); /* index, starts with 1 */ lua_pushoutfit(L,o[i]); /* value = LuaOutfit */ lua_rawset(L,-3); /* store the value in the table */ } return 1; }