Back to Index Page generated: Dec 20, 2024, 7:22:10 AM

Expansion UsefulMFDs

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Two MFDs: General Info (info on player and ship status) and Market of Cargo (prices and quantities in main market for ship's cargo) Two MFDs: General Info (info on player and ship status) and Market of Cargo (prices and quantities in main market for ship's cargo)
Identifier oolite.oxp.zirael.UsefulMFDs oolite.oxp.zirael.UsefulMFDs
Title UsefulMFDs UsefulMFDs
Category HUDs HUDs
Author Zirael Zirael
Version 0.6 0.6
Tags mfd mfd
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://aegidian.org/bb/viewtopic.php?f=4&t=16104 n/a
Download URL https://wiki.alioth.net/img_auth.php/5/51/UsefulMFDs.0.6.oxz n/a
License CC BY-NC-SA 3.0 CC BY-NC-SA 3.0
File Size n/a
Upload date 1660000265

Documentation

Also read http://wiki.alioth.net/index.php/UsefulMFDs

Readme.txt

Useful MFDs OXP
------------------------------------
v0.6, by Zirael

This OXP creates two MFDs:

General Info

Contains information on the ship, player, date, etc:

    Ship Name
    Service Level
    Mass
    Re-sale Price
    Next Revision Price
    Fuel
    Solar Wind (if Sun Gear OXP is installed)
    Credit Balance
    legal Status
    Rating
    Parcel Reputation
    Date


Market

Contains the price and avilability of the carried cargo at the Main Station:

    <quantity carried> <commodity> -> <quantity at Main Station> at <price at Main Station>



License 
-------

CC BY-NC-SA 3.0 - Creative Commons Attribution-NonCommercial-ShareAlike 3.0 (https://creativecommons.org/licenses/by-nc-sa/3.0/)

Change log
----------

v0.6
* updates sun reference in timer function when exiting witchspace.

v0.5
* Deals with interstellar space in Market MFD.

v0.4
* Made Market and General Info as two separate MFDs.
* Re-designed the Market and Generral Info MFDs.
* Made compatible with HUD Selector.

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         = "useful_MFDs";
this.author       = "Zireael";
this.copyright    = "2013 Zireael";
this.description  = "Makes MFDs more useful by displaying some info";
this.version      = "0.6";
this.licence      = "CC BY-NC-SA 3.0";

this.$updateTimer;
this.$count = 0;

//-----------------------------------------------------------------------------------
this.startUpComplete = function() {
    this.$player = player;
    this.$ship = this.$player.ship;
    this.$sun = system.sun;
    this.$systemMarket = system.mainStation.market;
    this.$station = this.$ship.dockedStation;
    this.$stationName = this.$station.displayName;
    this.$registerHUDSelector();
    this.$updateMFDs();
}

//-----------------------------------------------------------------------------------
this.shipDockedWithStation = function(station) {
    this.$station = station;
    this.$stationName = this.$station.displayName;
}

//-----------------------------------------------------------------------------------
this.shipLaunchedFromStation = this.shipExitedWitchspace = function() {
    var _player = this.$player;
    this.$sun = system.sun;
    this.$count = 0;
    this.$station = null;
    this.$stationName = null;
    this.$showGeneralInfo.sun = this.$sun;
    this.$systemMarket = (system.mainStation ? system.mainStation.market : null);
    this.$showStationMarket();
    
    
    if (this.$updateTimer)
        this.$updateTimer.start();
    else
        this.$updateTimer = new Timer(this, this.$updateMFDs.bind(this), 0, 1);
}

//-----------------------------------------------------------------------------------
this.shipWillDockWithStation = this.shipWillEnterWitchspace = function() {
    if (this.$updateTimer && this.$updateTimer.isRunning)
        this.$updateTimer.stop();
}

//-----------------------------------------------------------------------------------
this.playerBoughtNewShip = this.playerReplacedShip = function() {
    this.$ship = player.ship;
}




//-----------------------------------------------------------------------------------
this.$registerHUDSelector = function() {
    var ws = worldScripts.hudselector;
    if (!ws) return;
    ws.$HUDSelectorAddMFD("useful_MFDs", "useful_MFD_general_info");
    ws.$HUDSelectorAddMFD("useful_MFDs", "useful_MFD_market");
}

//-----------------------------------------------------------------------------------
this.$updateMFDs = function _usefulMFDs_updateMFDs() {
    this.$count += 1;
    this.$showGeneralInfo();
    if (this.$count % 5 === 0) {
        this.$showStationMarket();
    }
}

//-----------------------------------------------------------------------------------
this.$showGeneralInfo = function _usefulMFDs_showGeneralInfo() {
    var that = _usefulMFDs_showGeneralInfo;
    var wsAstroLib = (that.wsAstroLib = that.wsAtroLib || worldScripts.AstroLibrary);
    var _player = (that._player = that._player || player);
    var ship = (that._ship = that._ship || this.$ship);
    var sun = (that.sun = that.sun || this.$sun);
    var solarwind = (wsAstroLib ? wsAstroLib.$astroLib_SolarWind(ship.position.distanceTo(sun)) : null);

    var txt =  ship.displayName;
    txt += "\nService Level: " + ship.serviceLevel + "%";
    txt += ", Mass: "+(ship.mass/1000).toFixed(1)+"t";
    txt += "\nRe-sale Price: " + ship.price*0.75 + " Cr";
    txt += "\nNext Revision: " + ship.renovationMultiplier*ship.renovationCost/10 + " Cr";
    txt += "\nFuel: "+ship.fuel.toFixed(1)+" LY";
    if (solarwind != null) txt += ", Solar Wind: "+solarwind.toFixed(3)+" LY/min";
    txt += "\nCredits: " + _player.credits.toFixed(1) + "₢";
    txt += "\nLegal Status : " + _player.legalStatus + " (" + _player.bounty + ")";
    txt += "\nRating: " + _player.rank + " (" + _player.score + ")";
    txt += "\nParcel Rep.: "+_player.parcelReputationPrecise.toFixed(2);
    txt += "\nCurrent date: " + this.$setDateSince(3142, 2, 21);
    ship.setMultiFunctionText("useful_MFD_general_info", txt, true);
}

//-----------------------------------------------------------------------------------
this.$showStationMarket = function _usefulMFDs_showStationMarket() {
    var ship = this.$ship;
    var sysMarket = this.$systemMarket;
    var _manifest = ship.manifest.list;
    var z = _manifest.length;
    var msg = ((z > 0) ? "Market for the ship's cargo" : "No cargo");
    var m, c, qtt, price;
    while (z--) {
        m = _manifest[z];
        c = m.commodity;
        if (sysMarket) {
            qtt = sysMarket[c].quantity;
            price = sysMarket[c].price / 10;
        }
        if ( m.quantity > 0) {
            msg += "\n"+m.quantity+m.unit+" "+m.displayName+" -> "+(sysMarket ? qtt+m.unit+" at "+formatCredits(price,true,true) : "No Main Station in range");
        }
    }
    ship.setMultiFunctionText("useful_MFD_market", msg, true);
}

//-----------------------------------------------------------------------------------
this.$setStartDate = function(year, month, day) {
   var startDate = new Date();
   startDate.setFullYear(year, month, day);
   return startDate.toLocaleString();
}

//-----------------------------------------------------------------------------------
this.$setDateSince = function(year, month, day) {
   var testDate = new Date();
   testDate.setFullYear(year, month, day);
   
   var secondsPassedTotal = clock.seconds - 2084004 * 86400.0;
   var hoursPassed = Math.floor(secondsPassedTotal / 3600);
   var minutesPassed = Math.floor((secondsPassedTotal % 3600) / 60);
   var secondsPassed = Math.floor(secondsPassedTotal % 60);
   
   testDate.setHours(hoursPassed);
   testDate.setMinutes(minutesPassed);
   testDate.setSeconds(secondsPassed);
   
   return testDate.toLocaleString();
}

//-----------------------------------------------------------------------------------
this.$killRate = function() {
  var days = clock.days - 2084004;
  var kills = player.score;

  return kills / days;
}

/*this.$showDamagedEquipment = function() {
    for (i = start; i < eqptCount; i++)
        {
                info = [eqptList oo_arrayAtIndex:i];
                name = [info oo_stringAtIndex:0];
                if([name length] > 42) name = [[name substringToIndex:40] stringByAppendingString:@"..."];
                
                damaged = ![info oo_boolAtIndex:1];
                if (damaged) glColor4f (1.0f, 0.5f, 0.0f, 1.0f); // Damaged items show up orange.
             //   else glColor4f (1.0f, 1.0f, 0.0f, 1.0f);
}*/