Back to Index Page generated: Nov 12, 2024, 11:02:04 PM

Expansion Manifest MFD

Content

Warnings

  1. Information URL mismatch between OXP Manifest and Expansion Manager string length at character position 0

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Shows manifest information in an MFD. Great for miners, scavengers and others in constant need of cargo hold information. Shows manifest information in an MFD. Great for miners, scavengers and others in constant need of cargo hold information.
Identifier oolite.oxp.spara.manifest_mfd oolite.oxp.spara.manifest_mfd
Title Manifest MFD Manifest MFD
Category HUDs HUDs
Author spara spara
Version 1.1.2 1.1.2
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL n/a
Download URL https://wiki.alioth.net/img_auth.php/8/89/Manifest_mfd_1.1.2.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1610873355

Documentation

Also read http://wiki.alioth.net/index.php/Manifest%20MFD

manifest_mfd_readme_&_license.txt

Manifest MFD OXP ver 1.1.2 (3.8.2015)

Author: spara (Mika SpÄra)

_Overview_

Show cargo manifest information in an MFD. Great for miners, scavengers and anyone in need of quick manifest information. Equipment costs 550 credits and is available from TL5 and up stations.

_Other OXPs_

This oxp tracks the changes of used cargo space, thus catching scooping, jettisoning and destruction of cargo. It does not however note changes of cargo contents. For that an OXP changing the contents of an container in the cargo hold should notify this script by calling
notifyCargoChange().

Just add this to your script after you have changed the contents of a container:

if (worldScripts["manifest_mfd"])
	worldScripts["manifest_mfd"].notifyCargoChange();

_Requirements_

* Oolite 1.80 or higher

------

This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 4.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/

Equipment

Name Visible Cost [deci-credits] Tech-Level
Manifest MFD yes 5500 5+

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
Config/script.js
"use strict";

this.name               = "manifest_mfd";
this.author               = "spara";
this.description         = "Manifest info as an MFD";

//public function to notify about content changes
this.notifyCargoChange = function() {
	this.$updateManifestMFD();
}

//tracks changes in cargo space
this.$prevCargoSpaceUsed = player.ship.cargoSpaceUsed;

//update the mfd message and start a framecallback on launch
this.shipWillLaunchFromStation = function() {
	this.$updateManifestMFD();
	if (!this.$manifestMFD) {
		this.$manifestMFD = addFrameCallback(this.$manifestMonitor.bind(this));
	}
}

//remove framecallback on docking
this.shipWillDockWithStation = function() {
	if (this.$manifestMFD) {
		removeFrameCallback(this.$manifestMFD);
		delete this.$manifestMFD;
	}
}

//monitor volume changes in cargo hold.
this.$manifestMonitor = function() {
	var currCargoSpaceUsed = player.ship.cargoSpaceUsed;
	//cargo scooped, destroyed or jettisoned
	if (currCargoSpaceUsed !== this.$prevCargoSpaceUsed) {
		this.$updateManifestMFD();
		this.$prevCargoSpaceUsed = currCargoSpaceUsed;
	}
}

//update the mfd message
this.$updateManifestMFD = function() {
	if (player.ship.equipmentStatus("EQ_MANIFEST_MFD") === "EQUIPMENT_OK") {
		var message = "Cargo " + player.ship.cargoSpaceUsed + " t (" + player.ship.cargoSpaceCapacity + " t):\n";
		if (manifest.list.length === 0) message = message + " None.";
		else {
			var pieces = new Array();
			for (var i = 0; i < manifest.list.length; i++) {
				var m = manifest.list[i];
				pieces.push(m.quantity + " " + String.fromCharCode(215) + " "+ m.displayName);
			}
			var twoColumnRows = pieces.length - 9;
			var i = 0;
			if (twoColumnRows > 0) {
				var hairSpace = String.fromCharCode(31);
				var hairSpaceLength = defaultFont.measureString(hairSpace);
				for (i = 0; i < twoColumnRows; i++) {
					var line = " " + pieces[i];
					var currentLength = global.defaultFont.measureString(line);
					var padsNeeded = Math.floor((7.5 - currentLength) / hairSpaceLength);
					if (padsNeeded >= 1) {
						var pads = new Array(padsNeeded).join(hairSpace);
					}
					line = line + pads;
					message = message + line + pieces[i+9] + "\n";
				}
			}
			var rows = 9;
			if (pieces.length < 9) rows = pieces.length;
			for (var j = i; j < rows; j++) {
				message = message + " " + pieces[j] + "\n";
			}
		}
		player.ship.setMultiFunctionText("manifest_mfd", message);
	}
	else player.ship.setMultiFunctionText("manifest_mfd", null);
}