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

Expansion Contracted Goods Reminder

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description If you are doing a cargo contract and mistakenly sell the goods on the market screen, this will immediately pop up a reminder that you needed that cargo to deliver elsewhere. If you are doing a cargo contract and mistakenly sell the goods on the market screen, this will immediately pop up a reminder that you needed that cargo to deliver elsewhere.
Identifier oolite.oxp.Wildeblood.Contracted_Goods_Reminder oolite.oxp.Wildeblood.Contracted_Goods_Reminder
Title Contracted Goods Reminder Contracted Goods Reminder
Category Miscellaneous Miscellaneous
Author Wildeblood Wildeblood
Version 1.0.0.1 1.0.0.1
Tags market market
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://aegidian.org/bb/viewtopic.php?f=4&t=11123 n/a
Download URL https://wiki.alioth.net/img_auth.php/4/4e/Contracted_Goods_Reminder.oxz n/a
License CC-BY-NC-SA 3.0 CC-BY-NC-SA 3.0
File Size n/a
Upload date 1610873299

Documentation

Also read http://wiki.alioth.net/index.php/Contracted%20Goods%20Reminder

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    = "Contracted Goods Reminder";
this.version = "1.0";

/* ====================================================================================
			EVENT HANDLERS
======================================================================================= */

    this.guiScreenChanged = function (to, from) {
        "use strict";
        if (player.ship.docked &&
            to === "GUI_SCREEN_MARKET") {
            this._reserveGoodsForContracts();
        }
    }

    this._reserveGoodsForContracts = function () {
        "use strict";
        this.$reservedGoods = {};
        var arrayLength = player.ship.contracts.length;
        if (arrayLength) {
            for (var i = 0; i < arrayLength; i++) {
                var commodity = player.ship.contracts[i].commodity;
                var quantity  = player.ship.contracts[i].quantity;
                var reserve   = this.$reservedGoods[commodity];
                if (reserve) {
                    this.$reservedGoods[commodity] += quantity;
                } else {
                    this.$reservedGoods[commodity] = quantity;
                }
            }
        }
    }

    this.playerSoldCargo = function (commodity, quantity, unitPrice) {
        "use strict";
        var panic = false;
        var reserve = this.$reservedGoods[commodity];
        if (reserve && !manifest[commodity]) {
            panic = true;
        } else if (reserve && reserve > manifest[commodity]) {
            panic = true;
        }
        if (panic) {
            var displayName = displayNameForCommodity(commodity);
            player.consoleMessage("You need at least " + reserve + " units of " + displayName.toLowerCase() + " to fulfil your contracts.", 6);
        }
    }

/* ====================================================================================
			THE END
======================================================================================= */