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

Expansion 'No Market' Notification

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Displays a message instead of an unusable market screen. Displays a message instead of an unusable market screen.
Identifier oolite.oxp.phkb.NoMarketNotification oolite.oxp.phkb.NoMarketNotification
Title 'No Market' Notification 'No Market' Notification
Category Miscellaneous Miscellaneous
Author phkb phkb
Version 1.4 1.4
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL https://wiki.alioth.net/index.php/%27No_Market%27_Notification n/a
Download URL https://wiki.alioth.net/img_auth.php/3/3c/NoMarketNotification.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1728881228

Documentation

Also read http://wiki.alioth.net/index.php/'No%20Market'%20Notification

readme.txt

No Market Notification
by Nick Rogers

Overview
========
This OXP aims to make it clearer to players who are docked at a station that has no market available. Instead of showing a list of commodities with zero values, a simple message is displayed, informing the player there is no market available, and then sending the player to the F5F5 Manifest screen, where details of the contents of the player's hold can be viewed.

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
===============
1.4
- Made compatible with Feudal States OXP.

1.3
- Changed methodology for determining if a station doesn't have a market (sum of core commodity prices equal to zero).

1.2
- Improved integration with Market Ads.

1.1
- Improved integration with Market Observer.

1.0
- Initial release.

Equipment

This expansion declares no equipment.

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Config/script.js
"use strict";
this.name        = "NoMarketNotification"; 
this.author      = "phkb";
this.copyright   = "2018 phkb";
this.description = "Display a message instead of an unusable market screen.";
this.licence     = "CC BY-NC-SA 4.0";

this._noMarket = false;
this._cargoTypes = ["food", "textiles", "radioactives", "slaves", "liquor_wines", "luxuries", "narcotics", "computers", "machinery", "alloys", "firearms", "furs", "minerals", "alien_items", "gold", "platinum", "gem_stones"];

//-------------------------------------------------------------------------------------------------------------
this.shipWillDockWithStation = function(station) {
	var priceTotal = 0;
	this._noMarket = false;
	for (var i = 0; i < this._cargoTypes.length; i++) {
		priceTotal += station.market[this._cargoTypes[i]].price;
	}
	if (priceTotal == 0) this._noMarket = true;
}

//-------------------------------------------------------------------------------------------------------------
this.guiScreenWillChange = function(to, from) {

	// if market observer changes the HUD on the market screen, and we also run a mission screen
	// the "Press Space Commander" may not show, if the default HUD has allow Big GUI set.
	// so stop market observers "guiScreenChanged" event from firing, then put it back afterwards
	if (worldScripts.market_ads) {
		var ma = worldScripts.market_ads;
		if (to === "GUI_SCREEN_MARKET" && player.ship.docked && this._noMarket == true) {
			if (ma.guiScreenChanged) {
				ma.$hold_guiScreenChanged = ma.guiScreenChanged;
				delete ma.guiScreenChanged;
			}
		} else {
			if (ma.$hold_guiScreenChanged) {
				ma.guiScreenChanged = ma.$hold_guiScreenChanged;
				delete ma.$hold_guiScreenChanged;
			}
		}
	}
	if (worldScripts.market_observer3) {
		var mo = worldScripts.market_observer3;
		if (to === "GUI_SCREEN_MARKET" && player.ship.docked && this._noMarket == true) {
			if (mo.guiScreenChanged) {
				mo.$hold_guiScreenChanged = mo.guiScreenChanged;
				delete mo.guiScreenChanged;
			}
		} else {
			if (mo.$hold_guiScreenChanged) {
				mo.guiScreenChanged = mo.$hold_guiScreenChanged;
				delete mo.$hold_guiScreenChanged;
			}
		}
	}
}

//-------------------------------------------------------------------------------------------------------------
this.guiScreenChanged = function(to, from) {
	var p = player.ship;
	if (p.docked) {
		if (p.dockedStation.hasRole("planetFall_feudalStates") || p.dockedStation.hasRole("feudal-hunting-lodge")) return;
		if (to === "GUI_SCREEN_MARKET" && this._noMarket == true) {
			mission.runScreen({
				title: "No Market Available",
				message: "There is no commodities market available on this station. No goods can be bought or sold here.",
				exitScreen: "GUI_SCREEN_MANIFEST"
			});
		}
	}
}