/** * @brief Adds some mission cargo to the player. He cannot sell it nor get rid of it * unless he abandons the mission in which case it'll get eliminated. * * @luaparam cargo Name of the cargo to add. * @luaparam quantity Quantity of cargo to add. * @luareturn The id of the cargo which can be used in cargoRm. * @luafunc cargoAdd( cargo, quantity ) */ static int misn_cargoAdd( lua_State *L ) { const char *cname; Commodity *cargo; int quantity, ret; Mission *cur_mission; /* Parameters. */ cname = luaL_checkstring(L,1); quantity = luaL_checkint(L,2); cargo = commodity_get( cname ); /* Check if the cargo exists. */ if(cargo == NULL) { NLUA_ERROR(L, "Cargo '%s' not found.", cname); return 0; } cur_mission = misn_getFromLua(L); /* First try to add the cargo. */ ret = pilot_addMissionCargo( player.p, cargo, quantity ); mission_linkCargo( cur_mission, ret ); lua_pushnumber(L, ret); return 1; }
/** * @brief Adds some mission cargo to the player. He cannot sell it nor get rid of it * unless he abandons the mission in which case it'll get eliminated. * * @luaparam cargo Name of the cargo to add. * @luaparam quantity Quantity of cargo to add. * @luareturn The id of the cargo which can be used in rmCargo. * @luafunc addCargo( cargo, quantity ) */ static int misn_addCargo( lua_State *L ) { const char *cname; Commodity *cargo; int quantity, ret; /* Parameters. */ cname = luaL_checkstring(L,1); quantity = luaL_checkint(L,2); cargo = commodity_get( cname ); /* First try to add the cargo. */ ret = pilot_addMissionCargo( player, cargo, quantity ); mission_linkCargo( cur_mission, ret ); lua_pushnumber(L, ret); return 1; }