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

Expansion PlanetFallMarketSaver

Content

Warnings

  1. http://wiki.alioth.net/index.php/PlanetFallMarketSaver -> 404 Not Found
  2. 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 Save market in PlanetFall stations Save market in PlanetFall stations
Identifier oolite.oxp.SMax.PlanetFallMarketSaver oolite.oxp.SMax.PlanetFallMarketSaver
Title PlanetFallMarketSaver PlanetFallMarketSaver
Category Mechanics Mechanics
Author SMax SMax
Version 0.1 0.1
Tags PlanetFall, Market PlanetFall, Market
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/6/68/PlanetFallMarketSaver_0.1.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1610873324

Documentation

README.md

PlanetFallMarketSaver

By S Max

Save market in PlanetFall stations

License
=======
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/

Version History
===============
0.1

- Initial release

Equipment

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

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
/* global missionVariables log*/

this.name = "PlanetFallMarketSaver";
this.author = "SMax";
this.copyright = "2016 SMax";
this.licence = "CC-BY-NC-SA 4.0";
this.description = "Save market in PlanetFall stations";
this.version = "0.1";

"use strict";

this._DEBUG = false;

this._MARKET = {};
this._PLANET = null;

this.shipExitedWitchspace = function() {
	this._logger("shipExitedWitchspace");
	this._MARKET = {};
};

this.startUpComplete = function() {
	this._MARKET = {};
	var t = missionVariables.PlanetFallMarketSaver_DATA;
	this._logger("startUpComplete: " + t);
	if (t) {
		this._MARKET = JSON.parse(t);
	}
};

this.playerWillSaveGame = function() {
	missionVariables.PlanetFallMarketSaver_DATA = JSON.stringify(this._MARKET);
	this._logger("playerWillSaveGame: " + missionVariables.PlanetFallMarketSaver_DATA);
};

this.shipApproachingPlanetSurface = function(planet) {
	this._logger("shipApproachingPlanetSurface: " + planet.name);
	this._PLANET = planet;
};

this.shipLeavingPlanetSurface = function(planet) {
	this._logger("shipLeavingPlanetSurface: " + planet.name);
	this._PLANET = null;
};

this.shipDockedWithStation = function(station) {
	this._logger("shipDockedWithStation: " + station.primaryRole);
	if (this._PLANET) {
		var id = this.getID(station, this._PLANET);
		if (this._MARKET[id]) {
			var market = this._MARKET[id];
			for (var i = 0; i < market.length; i++) {
				var m = market[i];
				station.setMarketPrice(m.k, m.p);
				station.setMarketQuantity(m.k, m.q);
			}
		}
	}
};

this.shipWillLaunchFromStation = function(station) {
	this._logger("shipWillLaunchFromStation: " + station.primaryRole);
	if (this._PLANET) {
		var id = this.getID(station, this._PLANET);
		var market = station.market;
		var res = [];
		for (var k in market) {
			var i = {
				k: k,
				q: market[k].quantity,
				p: market[k].price
			};
			res.push(i);
		}
		this._MARKET[id] = res;
	}
};

this._logger = function(msg) {
	if (this._DEBUG) {
		log(this.name, msg);
	}
};

this.getID = function(station, planet) {
	var id = {
		n: planet.name,
		r: station.primaryRole
	};
	return JSON.stringify(id);
};