Back to Index Page generated: May 8, 2024, 6:16:03 AM

Expansion Vacuum Pump

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Consolidates multiple small quantities of Gold, Platinum or Gem Stones into the minimum number of Tonne Containers that they will fit into. Consolidates multiple small quantities of Gold, Platinum or Gem Stones into the minimum number of Tonne Containers that they will fit into.
Identifier oolite.oxp.Neelix.VacuumPump oolite.oxp.Neelix.VacuumPump
Title Vacuum Pump Vacuum Pump
Category Equipment Equipment
Author Neelix Neelix
Version 0.3 0.3
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Vacuum_Pump n/a
Download URL https://wiki.alioth.net/img_auth.php/d/d0/VacuumPump_0.3.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1610873477

Documentation

Also read http://wiki.alioth.net/index.php/Vacuum%20Pump

Equipment

Name Visible Cost [deci-credits] Tech-Level
Vacuum Pump yes 15000 5+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/vacuum_pump.js
"use strict";
this.author			= "Neelix"; 
this.copyright		= "© 2011-2014 Neelix."; 
this.licence		= "CC-BY-NC-SA 4.0";
this.version		= "0.3"; 
this.name			= "VacuumPump";
this.description	= "Vacuum Pump World Script";


this.startUp = function() {
	//Prepare data storage and mode selection
	this.$commodities = [
		{commName: "gold", mask: 1}, 
		{commName: "platinum", mask: 2}, 
		{commName: "gem_stones", mask: 4}
	];
	this.$mode = 0;
	//Prepare data storage for "crushed cargo pods" functionality
	this.$alloysStored = missionVariables.vacuumPump_alloysStored;
	if (!this.$alloysStored) {
		this.$alloysStored = 0;
	}
	this.$maxStorage = 20;
	//setup sound
	this.$pumpSound = new SoundSource;
	this.$pumpSound.sound = "vacuumpump.ogg";
	this.$pumpSound.loop = false;
}

this.playerWillSaveGame = function() {
	//Keep record of internally stored crushed pods across sessions
	missionVariables.vacuumPump_alloysStored = this.$alloysStored;
}

this.shipWillLaunchFromStation = function() {
	// Record amount of gold, platinum and gem stones stored in the safe on launch.
	if (manifest.gold > 499) {
		this.$commodities[0].inSafe = 499;
	} else {
		this.$commodities[0].inSafe = manifest.gold;
	}
	if (manifest.platinum > 499) {
		this.$commodities[1].inSafe = 499;
	} else {
		this.$commodities[1].inSafe = manifest.platinum;
	}
	if (manifest.gemStones > 499999) {
		this.$commodities[2].inSafe = 499999;
	} else {
		this.$commodities[2].inSafe = manifest.gemStones;
	}
}

this._startPump = function() {
	var $i, $j;
	var $ml = manifest.list;
	var $commInfo = [{},{},{}];
	var $activated = false;
	var $totalRecovered = 0;
	var $alloyTotal = 0;

	//Calculate how much of each commodity is in the hold, and whether or not it needs to be consolidated
	for ($i = 0; $i < $ml.length; $i++) {
		for ($j = 0; $j < 3; $j++) {
			if ($ml[$i].commodity == this.$commodities[$j].commName) {
				$commInfo[$j].index = $i;
				$commInfo[$j].inHold = $ml[$i].quantity-this.$commodities[$j].inSafe;
				$commInfo[$j].minContainers = Math.ceil($commInfo[$j].inHold / (($j == 2) ? 1000000 : 1000));
				$commInfo[$j].pumpUseful = ($commInfo[$j].minContainers < $ml[$i].containers) ? true : false;
			}
		}
	}
	// Actvate pump based on mode and whether or not it is useful for a given commodity
	for ($j = 0; $j < 3; $j++) {
		if (player.alertCondition == 1 && player.ship.energy >= 64 && $commInfo[$j].pumpUseful && 
			(this.$commodities[$j].mask & this.$mode || this.$mode == 0 && !$activated)) {
			
			this.$pumpSound.play();
			this._pumpAct($j,$commInfo[$j]);
			$totalRecovered += $ml[$commInfo[$j].index].containers - $commInfo[$j].minContainers;
			$activated = true;
			//Convert cargo pods to alloys and add to internal storage or cargo bay
			this.$alloysStored += $totalRecovered;
			while (this.$alloysStored >= this.$maxStorage) {
				manifest.alloys += 1;
				this.$alloysStored -= this.$maxStorage;
				$alloyTotal += 1;
			}
		}
	}
	if ($activated) {
		//notify player how much cargo space has been recovered.
		player.consoleMessage("Cargo load " + player.ship.cargoSpaceUsed + " of " + player.ship.cargoSpaceCapacity + " t. ",10);
		player.consoleMessage($totalRecovered + " t. Recovered",10);
		if ($alloyTotal > 0) {
			player.consoleMessage($alloyTotal + " t Alloys added to Cargo bay",10);
		}
	} else {
		//equipment failed to operate - notify the player
		if (player.alertCondition != 1) {
			player.consoleMessage("Vacuum Pump can not be operated unless condition is Green",5);
		} else {
			player.consoleMessage("Unable to recover any cargo space",5);
		}
	}
}   

this._pumpAct = function($commNo, $commData) {
	//adding entire amount of the item to the manifest in one go should put it in the minimum number of containers.
	player.ship.energy -= 48;
	switch ($commNo) {
		case 0:
			manifest.gold -= $commData.inHold;
			manifest.gold += $commData.inHold;
			player.consoleMessage("Gold Consolidated",7);
			break;
		case 1:
			manifest.platinum -= $commData.inHold;
			manifest.platinum += $commData.inHold;
			player.consoleMessage("Platinum Consolidated",7);
			break;
		case 2:
			manifest.gemStones -=$commData.inHold;
			manifest.gemStones +=$commData.inHold;
			player.consoleMessage("Gem Stones Consolidated",7);
	}
}

this._modeCycle = function() {
	this.$mode++;
	if (this.$mode == 8) {
		this.$mode = 0;
	}
	switch (this.$mode) {
		case 0:
			player.consoleMessage("Vacuum Pump: Single Use Mode");
			break;
		case 1:
			player.consoleMessage("Vacuum Pump: Gold Only");
			break;
		case 2:
			player.consoleMessage("Vacuum Pump: Platinum Only");
			break;
		case 3:
			player.consoleMessage("Vacuum Pump: Gold and Platinum");
			break;
		case 4:
			player.consoleMessage("Vacuum Pump: Gem Stones Only");
			break;
		case 5:
			player.consoleMessage("Vacuum Pump: Gold and Gem Stones");
			break;
		case 6:
			player.consoleMessage("Vacuum Pump: Platinum and Gem Stones");
			break;
		case 7:
			player.consoleMessage("Vacuum Pump: Everything");
	}
}
Scripts/vacuum_pump_eq.js
"use strict";
this.author			= "Neelix"; 
this.copyright		= "© 2011-2014 Neelix."; 
this.licence		= "CC-BY-NC-SA 4.0";
this.version		= "0.3"; 
this.name			= "VacuumPumpEQ";
this.description	= "Vacuum Pump Equipment Script";

this.activated = function() {
		worldScripts["VacuumPump"]._startPump.bind(worldScripts["VacuumPump"])();
}

this.mode = function() {
		worldScripts["VacuumPump"]._modeCycle.bind(worldScripts["VacuumPump"])();
}