| Scripts/extra_tanks_script.js | "use strict";
// Standard attributes 
this.name           = "extra_tanks_script.js"; 
this.author         = "Smivs"; 
this.copyright      = "(C) Smivs";
this.licence        = "Creative Commons Attribution - Non-Commercial - Share Alike 4.0";
this.version        = "1.8"; 
this.description    = "Script to control tanks and refills, and upgrade reserve to auxiliary tank."; 
this.startUp = function()
// check for old-version variables at start
{
  if (missionVariables.TL_FOR_EQ_RESERVE_TANK_EMPTY || missionVariables.TL_FOR_EQ_AUX_TANK_EMPTY)
    {
// set mission flag
      this.missionFlag = "NO";
      this.startUpComplete;
      delete this.startUp;
  }
}
this.missionScreenOpportunity = function()
// check for old-version variables 
{
  if (missionVariables.TL_FOR_EQ_RESERVE_TANK_EMPTY || missionVariables.TL_FOR_EQ_AUX_TANK_EMPTY)
    {
// Do nothing now if tank is damaged
      if (player.ship.docked && player.ship.equipmentStatus("EQ_RESERVE_TANK" || "EQ_RESERVE_TANK_EMPTY" || "EQ_AUX_TANK" || "EQ_AUX_TANK_EMPTY") == "EQUIPMENT_DAMAGED") 
        {
          return;
        }
// otherwise clean up and replace old status variables from previous versions and run mission screen
      if (player.ship.docked && player.ship.equipmentStatus("EQ_RESERVE_TANK") == "EQUIPMENT_OK")
        {
          delete missionVariables.TL_FOR_EQ_RESERVE_TANK_EMPTY;
          missionVariables.extra_tank_status = "RESERVE_TANK_FULL";
          mission.runScreen({title: "!!! Fuel Tank Safety Notice !!!", messageKey: "extraTank_B_C_Update"}); 
          this.missionFlag = "DONE";
        }
      if (player.ship.docked && player.ship.equipmentStatus("EQ_RESERVE_TANK_EMPTY") == "EQUIPMENT_OK")
        {
          delete missionVariables.TL_FOR_EQ_RESERVE_TANK_EMPTY;
          missionVariables.extra_tank_status = "RESERVE_TANK_EMPTY";
          mission.runScreen({title: "!!! Fuel Tank Safety Notice !!!", messageKey: "extraTank_B_C_Update"}); 
          this.missionFlag = "DONE";
        }
      if (player.ship.docked && player.ship.equipmentStatus("EQ_AUX_TANK") == "EQUIPMENT_OK")
        {
          delete missionVariables.TL_FOR_EQ_AUX_TANK_EMPTY;
          missionVariables.extra_tank_status = "AUX_TANK_FULL";
          mission.runScreen({title: "!!! Fuel Tank Safety Notice !!!", messageKey: "extraTank_B_C_Update"}); 
          this.missionFlag = "DONE";
        }
      if (player.ship.docked && player.ship.equipmentStatus("EQ_AUX_TANK_EMPTY") == "EQUIPMENT_OK")
        {
          delete missionVariables.TL_FOR_EQ_AUX_TANK_EMPTY;
          missionVariables.extra_tank_status = "AUX_TANK_EMPTY";
          mission.runScreen({title: "!!! Fuel Tank Safety Notice !!!", messageKey: "extraTank_B_C_Update"}); 
          this.missionFlag = "DONE";
        }
    } 
}
// handle purchase of tanks and refills
this.playerBoughtEquipment = function(equipment)
{
  if (equipment == "EQ_RESERVE_TANK")
    {
      missionVariables.extra_tank_status = "RESERVE_TANK_FULL";
    }
  if (equipment == "EQ_AUX_TANK")
    {
      missionVariables.extra_tank_status = "AUX_TANK_FULL";
    }
  if (equipment == "EQ_1LY_CHARGE")
    {
      player.ship.removeEquipment("EQ_1LY_CHARGE");
      player.ship.removeEquipment("EQ_RESERVE_TANK_EMPTY");
      player.ship.awardEquipment("EQ_RESERVE_TANK");
      missionVariables.extra_tank_status = "RESERVE_TANK_FULL";
    }
  if (equipment == "EQ_3LY_CHARGE")
    {
      player.ship.removeEquipment("EQ_3LY_CHARGE");
      player.ship.removeEquipment("EQ_AUX_TANK_EMPTY");
      player.ship.awardEquipment("EQ_AUX_TANK");
      missionVariables.extra_tank_status = "AUX_TANK_FULL";
    }
  if (equipment== "EQ_UPGRADE_TANK")
    {
      player.ship.removeEquipment("EQ_RESERVE_TANK_EMPTY");
      player.ship.removeEquipment("EQ_UPGRADE_TANK");
      player.ship.awardEquipment("EQ_AUX_TANK");
      missionVariables.extra_tank_status = "AUX_TANK_FULL";
    }
}
this.activated = function()
{
// if reserve tank activated
  if (player.ship.fuel === 0 && player.ship.equipmentStatus ("EQ_RESERVE_TANK") == "EQUIPMENT_OK" && missionVariables.extra_tank_status == "RESERVE_TANK_FULL")
     {
       this.ship.fuel += 1.0;
       player.ship.removeEquipment("EQ_RESERVE_TANK");
       player.ship.awardEquipment("EQ_RESERVE_TANK_EMPTY");
       missionVariables.extra_tank_status = "RESERVE_TANK_EMPTY";
       player.consoleMessage("Fuel transferred to Main Tank");
     }
// unless the main tank is too full
  else if (player.ship.fuel > 0 && player.ship.equipmentStatus ("EQ_RESERVE_TANK") == "EQUIPMENT_OK" && missionVariables.extra_tank_status == "RESERVE_TANK_FULL")
     {
       player.consoleMessage("Fuel transfer cancelled - Main Tank must be empty");
       return;
     }
// or the reserve tank is empty
  else if (player.ship.fuel > 0 && player.ship.equipmentStatus ("EQ_RESERVE_TANK_EMPTY") == "EQUIPMENT_OK" && missionVariables.extra_tank_status == "RESERVE_TANK_EMPTY")
     {
       player.consoleMessage("Fuel transfer un-available - Reserve Tank is empty.");
       return;
     }
// if auxiliary tank activated
  else if (player.ship.fuel === 0 && player.ship.equipmentStatus ("EQ_AUX_TANK") == "EQUIPMENT_OK" && missionVariables.extra_tank_status === "AUX_TANK_FULL")
     {
        this.ship.fuel += 3.0;
        player.ship.removeEquipment("EQ_AUX_TANK");
        player.ship.awardEquipment("EQ_AUX_TANK_EMPTY");
	missionVariables.extra_tank_status = "AUX_TANK_EMPTY";
        player.consoleMessage("Fuel transferred to Main Tank");
      }
// unless the main tank is too full
  else if (player.ship.fuel > 0 && player.ship.equipmentStatus ("EQ_AUX_TANK") == "EQUIPMENT_OK" && missionVariables.extra_tank_status === "AUX_TANK_FULL")
      {
        player.consoleMessage("Fuel transfer cancelled - Main Tank must be empty");
        return;
      }
// or the auxiliary tank is empty
  else if (player.ship.fuel > 0 && player.ship.equipmentStatus ("EQ_AUX_TANK_EMPTY") == "EQUIPMENT_OK" && missionVariables.extra_tank_status == "AUX_TANK_EMPTY")
      {
        player.consoleMessage("Fuel transfer un-available - Auxiliary Tank is empty.");
        return;
      }
}
this.allowAwardEquipment = function(equipment, ship, context)
// condition scripting for Refills and Upgrade to control availability
{
  if (equipment == "EQ_1LY_CHARGE")
    {
      if (context == "purchase" && player.ship.equipmentStatus("EQ_RESERVE_TANK_EMPTY") == "EQUIPMENT_OK" && missionVariables.extra_tank_status == "RESERVE_TANK_EMPTY")
	{
	  return true;
	}
    }
 if (equipment == "EQ_3LY_CHARGE")
    {
      if (context == "purchase" && player.ship.equipmentStatus("EQ_AUX_TANK_EMPTY") == "EQUIPMENT_OK" && missionVariables.extra_tank_status == "AUX_TANK_EMPTY")
	{
	  return true;
	}
    }
  if (equipment == "EQ_UPGRADE_TANK")
    {
      if (context == "purchase" && player.ship.equipmentStatus("EQ_RESERVE_TANK_EMPTY") == "EQUIPMENT_OK" && missionVariables.extra_tank_status == ("RESERVE_TANK_EMPTY"))
	{
	  return true;
	}
    }
}
 |