Beispiel #1
0
/**
 * @brief Sets a system's known state.
 *
 * @usage s:setKnown( false ) -- Makes system unknown.
 *    @luaparam s System to set known.
 *    @luaparam b Whether or not to set as known (defaults to false).
 *    @luaparam r Whether or not to iterate over the system's assets and jump points (defaults to false).
 * @luafunc setKnown( s, b )
 */
static int systemL_setknown( lua_State *L )
{
   int b, r, i;
   StarSystem *sys;

   r = 0;
   sys = luaL_validsystem(L, 1);
   b   = lua_toboolean(L, 2);
   if (lua_gettop(L) > 2)
      r   = lua_toboolean(L, 3);

   if (b)
      sys_setFlag( sys, SYSTEM_KNOWN );
   else
      sys_rmFlag( sys, SYSTEM_KNOWN );

   if (r) {
      if (b) {
         for (i=0; i < sys->nplanets; i++)
            planet_setKnown( sys->planets[i] );
         for (i=0; i < sys->njumps; i++)
            jp_setFlag( &sys->jumps[i], JP_KNOWN );
     }
     else {
         for (i=0; i < sys->nplanets; i++)
            planet_rmFlag( sys->planets[i], PLANET_KNOWN );
         for (i=0; i < sys->njumps; i++)
            jp_rmFlag( &sys->jumps[i], JP_KNOWN );
     }
   }
   return 0;
}
Beispiel #2
0
/**
 * @brief Sets a system's known state.
 *
 * @usage s:setKnown( false ) -- Makes system unknown.
 *    @luatparam System  s System to set known.
 *    @luatparam[opt=false] boolean b Whether or not to set as known.
 *    @luatparam[opt=false] boolean r Whether or not to iterate over the system's assets and jump points.
 * @luafunc setKnown( s, b, r )
 */
static int systemL_setknown( lua_State *L )
{
   int b, r, i;
   StarSystem *sys;

   NLUA_CHECKRW(L);

   r = 0;
   sys = luaL_validsystem(L, 1);
   b   = lua_toboolean(L, 2);
   if (lua_gettop(L) > 2)
      r   = lua_toboolean(L, 3);

   if (b)
      sys_setFlag( sys, SYSTEM_KNOWN );
   else
      sys_rmFlag( sys, SYSTEM_KNOWN );

   if (r) {
      if (b) {
         for (i=0; i < sys->nplanets; i++)
            planet_setKnown( sys->planets[i] );
         for (i=0; i < sys->njumps; i++)
            jp_setFlag( &sys->jumps[i], JP_KNOWN );
     }
     else {
         for (i=0; i < sys->nplanets; i++)
            planet_rmFlag( sys->planets[i], PLANET_KNOWN );
         for (i=0; i < sys->njumps; i++)
            jp_rmFlag( &sys->jumps[i], JP_KNOWN );
     }
   }

   /* Update outfits image array. */
   outfits_updateEquipmentOutfits();

   return 0;
}
Beispiel #3
0
/**
 * @brief Sets a planets's known state.
 *
 * @usage p:setKnown( false ) -- Makes planet unknown.
 *    @luatparam Planet p Planet to set known.
 *    @luatparam[opt=false] boolean b Whether or not to set as known.
 * @luafunc setKnown( p, b )
 */
static int planetL_setKnown( lua_State *L )
{
   int b, changed;
   Planet *p;

   NLUA_CHECKRW(L);

   p = luaL_validplanet(L,1);
   b = lua_toboolean(L, 2);

   changed = (b != (int)planet_isKnown(p));

   if (b)
      planet_setKnown( p );
   else
      planet_rmFlag( p, PLANET_KNOWN );

   /* Update outfits image array. */
   if (changed)
      outfits_updateEquipmentOutfits();

   return 0;
}
Beispiel #4
0
static int systemL_createPlanet( lua_State *L )
{
	int pos=0;

    StarSystem *sys = luaL_validsystem(L, ++pos);
    const char* name = luaL_checkstring(L, ++pos);
    double posX = luaL_checknumber(L, ++pos);
    double posY = luaL_checknumber(L, ++pos);
    const char* spaceGraphic = luaL_checkstring(L, ++pos);
    const char* exteriorGraphic = luaL_checkstring(L, ++pos);
    double presenceAmount = luaL_checknumber(L, ++pos);
    int presenceRange = luaL_checknumber(L, ++pos);
    const char* factionName = luaL_checkstring(L, ++pos);
    const char* description = luaL_checkstring(L, ++pos);
    const char* descriptionSettlements = luaL_checkstring(L, ++pos);
    const char* descriptionHistory = luaL_checkstring(L, ++pos);
    const char* descriptionBar = luaL_checkstring(L, ++pos);
    long population = luaL_checknumber(L, ++pos);
    double hide = luaL_checknumber(L, ++pos);
    const char* class = luaL_checkstring(L, ++pos);
    int serviceLand = luaL_checknumber(L, ++pos);
    const char* landingFunc = luaL_checkstring(L, ++pos);
    int refuel = luaL_checknumber(L, ++pos);
    int bar = luaL_checknumber(L, ++pos);
    int missions = luaL_checknumber(L, ++pos);
    int commodity = luaL_checknumber(L, ++pos);
    int outfits = luaL_checknumber(L, ++pos);
    int shipyard = luaL_checknumber(L, ++pos);
    int known = lua_toboolean(L, ++pos);
    
    if (strlen(factionName)==0)
        factionName=NULL;
    if (strlen(exteriorGraphic)==0)
        exteriorGraphic=NULL;
    if (strlen(description)==0)
        description=NULL;
    if (strlen(descriptionSettlements)==0)
    	descriptionSettlements=NULL;
    if (strlen(descriptionHistory)==0)
    	descriptionHistory=NULL;
    if (strlen(descriptionBar)==0)
        descriptionBar=NULL;
    if (strlen(landingFunc)==0)
        landingFunc=NULL;

    Planet* planet=planet_createNewPlanet( name ,0,spaceGraphic,exteriorGraphic,
                                          posX,posY,presenceAmount,presenceRange,factionName
                                          ,description,descriptionSettlements,descriptionHistory,descriptionBar,population,hide,class,
                                          serviceLand,landingFunc,refuel,bar,missions,commodity,outfits,shipyard);
    
    
    
    if (planet==NULL) {
        return -1;
    }
    
    planet->transient=1;

    system_addPlanet( sys, name );
    
    if (known)
    	planet_setKnown(planet);

    //space_refresh();

    return 0;
}