コード例 #1
0
ファイル: nlua_outfit.c プロジェクト: Superkoop/naev
/**
 * @brief Checks to see if two outfits are the same.
 *
 * @usage if o1 == o2 then -- Checks to see if outfit o1 and o2 are the same
 *
 *    @luaparam o1 First outfit to compare.
 *    @luaparam o2 Second outfit to compare.
 *    @luareturn true if both outfits are the same.
 * @luafunc __eq( o1, o2 )
 */
static int outfitL_eq( lua_State *L )
{
   LuaOutfit *a, *b;
   a = luaL_checkoutfit(L,1);
   b = luaL_checkoutfit(L,2);
   if (a->outfit == b->outfit)
      lua_pushboolean(L,1);
   else
      lua_pushboolean(L,0);
   return 1;
}
コード例 #2
0
ファイル: nlua_outfit.c プロジェクト: Superkoop/naev
/**
 * @brief Makes sure the outfit is valid or raises a Lua error.
 *
 *    @param L State currently running.
 *    @param ind Index of the outfit to validate.
 *    @return The outfit (doesn't return if fails - raises Lua error ).
 */
Outfit* luaL_validoutfit( lua_State *L, int ind )
{
   LuaOutfit *lo;
   Outfit *o;

   /* Get the outfit. */
   lo = luaL_checkoutfit(L,ind);
   o  = lo->outfit;
   if (o==NULL) {
      NLUA_ERROR(L,"Outfit is invalid.");
      return NULL;
   }

   return o;
}
コード例 #3
0
ファイル: nlua_outfit.c プロジェクト: VetHockey/naev
/**
 * @brief Makes sure the outfit is valid or raises a Lua error.
 *
 *    @param L State currently running.
 *    @param ind Index of the outfit to validate.
 *    @return The outfit (doesn't return if fails - raises Lua error ).
 */
Outfit* luaL_validoutfit( lua_State *L, int ind )
{
   Outfit *o;

   if (lua_isoutfit(L, ind))
      o  = luaL_checkoutfit(L,ind);
   else if (lua_isstring(L, ind))
      o = outfit_get( lua_tostring(L, ind) );
   else {
      luaL_typerror(L, ind, OUTFIT_METATABLE);
      return NULL;
   }

   if (o == NULL)
      NLUA_ERROR(L, "Outfit is invalid.");

   return o;
}