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

Expansion Flight Log

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Adds a simple log of the last 100 systems visited in the current galaxy (latest 10 viewable in-game), which can be dumped out to latest.log. Your kills and profit/loss made whilst in-system are also logged. Adds a simple log of the last 100 systems visited in the current galaxy (latest 10 viewable in-game), which can be dumped out to latest.log. Your kills and profit/loss made whilst in-system are also logged.
Identifier oolite.oxp.Thargoid.FlightLog oolite.oxp.Thargoid.FlightLog
Title Flight Log Flight Log
Category Equipment Equipment
Author Thargoid Thargoid
Version 1.11 1.11
Tags equipment equipment
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Flight_Log_OXP n/a
Download URL https://wiki.alioth.net/img_auth.php/1/19/FlightLog.oxz n/a
License Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme file Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme file
File Size n/a
Upload date 1610873240

Documentation

Also read http://wiki.alioth.net/index.php/Flight%20Log

Flight Log ReadMe & License.txt

Flight Log OXP by Thargoid.
Updates by phkb (v1.09 and following)

A little OXP by forum request of "Newt_Othis" and others to keep a log of the last 100 systems visited by witchspace (including interstellar space). In-game, a list of the most recent 10 of those systems visited can be accessed by going either to the ship's interface screen (F4 whilst docked) or whilst in flight via the manifest screen (F5-F5) and from there on to the short range chart screen (F6).

The list holds the last 100 systems visited plus the current one is also noted. It also records the number of kills made whilst in the system and the net credit balance change whilst there (profit and loss, with losses being negative obviously). If the list contains at least one visited system, it can also be dumped out to the latest.log file from this screen (this will dump out the full log, up to 100 entries long).

Requires v1.79 or later of Oolite. It will not run on older versions.

--------------------------------------------------------------

License:

This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with the following clauses:

* Whilst you are free (and encouraged) to re-use any of the scripting, models or texturing in this OXP, the usage must be distinct from that within this OXP. Unique identifiers such as (but not limited to) unique shipdata.plist entity keys, mission variables, script names (this.name), equipment identity strings (EQ_), description list arrays and entity roles must not be re-used without prior agreement. Basically if it's unique or would identify or overwrite anything in the original OXP, then you may not re-use it (for obvious compatibility reasons).
* rebundling of this OXP within another distribution is permitted as long as it is unchanged. The following derivates however are permitted and except from the above:
	* the conversion of files between XML and openStep.
	* the merging of files with other files of the same type from other OXPs.
* The license information (either as this file or merged into a larger one) must be included in the OXP.
* Even though it is not compulsory, if you are re-using any sizable or recognisable piece of this OXP, please let me know :)

Image from http://simpleicon.com/note_book.html.

--------------------------------------------------------------

Instructions:


For those who have downloaded the OXP version, unzip the file, and then move the folder "Flight Log 1.08.oxp" to the AddOns directory of your Oolite installation. Then start the game up and the ships should be added. 

The OXZ version downloaded via the Expansion manager should be installed and operational directly. For a manual download, move the .oxz folder to the addons directory and restart the game.

--------------------------------------------------------------

Version history:

31/08/2010 - Version 1.00, initial release.
03/09/2010 - Version 1.01, amended scripting to better trim the log after reports of problems on some systems.
24/01/2011 - Version 1.02, added kill count and credit level change per system to log, and also corrected minor capitalisation item.
13/02/2011 - Version 1.03, removal of upper limit, to allow running with 1.75
15/09/2012 - Version 1.04, script tweak to add the flight log to the F4 menu on Oolite 1.77 or higher
16/09/2012 - Version 1.05, add a shipped dock check that was omitted accidentally in v1.04
24/01/2013 - Version 1.06, removed the F5-F5-F6 route when docked (F4 only now), and up'd the minimum Oolite to 1.77
11/02/2014 - Version 1.07, expand the storage to 100 systems, with just the last 10 being displayed in-game.
07/08/2014 - Version 1.08, script adjusted to run on startUpComplete rather than startUp, to allow for non-main station saves.
08/12/2014 - Version 1.09, exiting log now returns to system interfaces screen
			   added "use strict" to script file
			   added a screenID parameter to the mission.runScreen functions.
			   removed access to full log inflight (no longer recommended in 1.81), added item to manifest screen instead
27/02/2015 - Version 1.10, fixed bug where kills in system with ID 0 were not showing up on the log.
17/12/2015 - Version 1.11, small code cleanup items, added overlay background image.
                           Updated screenID's to enable BGS background sounds.
--------------------------------------------------------------

Acknowledgements:

With thanks to Newt_Othis for the original inspiration and Switeck for the bug report on the length trimming problem. Idea for adding kills and credits from UK_Eliter and others.

And thanks to Ironfist for the bug report on the 1.04 missing docked check.

Thanks to Neelix for the heads-up about the non-main station save glitch and the fix recommendation.

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					= "FlightLog";
this.author					= "Thargoid";
this.copyright				= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description			= "Saves a list of systems visited, plus the kills and profit for each";
this.version				= "1.11";

this.startUpComplete = function()
	{
	this.maxLogLength = 100; // the max size of the log - minimum size should be 10 (the latest 10 are displayed in-game).
	this.blankArray = "";
	let setupCounter = 0; // reset the counter
	for(setupCounter = 0; setupCounter < this.maxLogLength; setupCounter++)
		{ this.blankArray = this.blankArray + "0:";	}
	this.blankArray = this.blankArray.substr(0, (this.blankArray.length - 1 )); // snip off the last :

	if(!missionVariables.flightLogMemory)
		{ // if this is the first run of the OXP
		missionVariables.flightLogMemory = this.blankArray;
		missionVariables.flightKillsMemory = this.blankArray;
		missionVariables.flightCreditsMemory = this.blankArray;
		missionVariables.flightKillsStore = player.score;
		missionVariables.flightCreditsStore = player.credits;
		}

	this.flightArray = missionVariables.flightLogMemory.split(":");
	this.killsArray = missionVariables.flightKillsMemory.split(":");
	this.creditsArray = missionVariables.flightCreditsMemory.split(":");

	this.baseKills = missionVariables.flightKillsStore;
	this.baseCredits = missionVariables.flightCreditsStore;

	if(this.flightArray.length !== this.maxLogLength) // just in case this.maxLogLength has been changed since last run.
		{
		let setupCounter = 0; // reset the counter
		for(setupCounter = this.flightArray.length; setupCounter < this.maxLogLength; setupCounter++)
			{ // this loop will run if the array is smaller than the max log size
			this.flightArray[setupCounter] = "0";
			this.killsArray[setupCounter] = "0";
			this.creditsArray[setupCounter] = "0";
			}
		this.$trimArrays(); // this will trim things down if the array is larger than the max log size
		}

	let setupCounter = 0; // reset the counter
	for(setupCounter = 0;setupCounter < this.flightArray.length;setupCounter++)
		{
		this.flightArray[setupCounter] *= 1; // to swap values from string to number
		this.killsArray[setupCounter] *= 1;
		this.creditsArray[setupCounter] *= 1;
		}
	this.$dockedCheck();
	}

this.shipDockedWithStation = function()
	{
	this.$dockedCheck();
	this.playerWillSaveGame();
	}

this.playerWillSaveGame = function()
	{
	missionVariables.flightKillsStore = this.baseKills;
	missionVariables.flightCreditsStore = this.baseCredits;
	}

this.$dockedCheck = function()
	{
	if (player.ship.docked)
		{
		player.ship.dockedStation.setInterface("FlightLog",
			{ title: "Flight log",
			category: "Logs",
			summary: "Displays the ships flight log.",
			callback: this.$showLog.bind(this) });
		}
	}

this.guiScreenChanged = function(to, from)
	{
	if(from == "GUI_SCREEN_MARKET" || from == "GUI_SCREEN_EQUIP_SHIP" || from == "GUI_SCREEN_SHIPYARD" || from == "GUI_SCREEN_STATUS")
		{ //  refresh the mission variables if we come from market/equipment/shipyard or status screens
		this.playerWillSaveGame();
		}

	// showing mission screen during flight is no longer recommended
	//if(player.ship.docked || to != "GUI_SCREEN_SHORT_RANGE_CHART" || from != "GUI_SCREEN_MANIFEST")
	//	{ // access main screen only from manifest to short range chart when in flight (via F4 when docked)
	//	return;
	//	}
	//this.$showLog();
	}

this.guiScreenWillChange = function (to, from) {
	if (to === "GUI_SCREEN_MANIFEST") {
		if (!player.ship.docked) {
			if(system.ID == -1) {
				mission.setInstructions("You are currently in interstellar space (" + (player.score - this.baseKills) + " kills, " + (Math.floor(10 * (player.credits - this.baseCredits)) / 10) + "cr).", this.name);
			} else {
				mission.setInstructions("You are currently in the " + system.name + " system in galaxy " + (galaxyNumber + 1) + " (" + (player.score - this.baseKills) + " kills, " + (Math.floor(10 * (player.credits - this.baseCredits)) / 10) + "cr).", this.name);
			}
		} else {
			mission.setInstructions(null, this.name);
		}
	}
}

this.$showLog = function() {
	if(this.flightArray[this.flightArray.length - 1] == 0) {// if the last entry is 0, then assume the array is blank (all zero)
		mission.runScreen({screenID:"oolite-flightlog-main-map", title:"Flight Log", overlay:{name:"fl-note_book.png", height:546}, exitScreen:"GUI_SCREEN_INTERFACES", messageKey:"flightLog_empty"});
		if(system.ID == -1) {
			mission.addMessageText("\nYou are currently in interstellar space.");
		} else {
			mission.addMessageText("\nYou are currently in the " + system.name + " system in galaxy " + (galaxyNumber + 1) + ".");
		}
		return;
	}

	mission.runScreen({screenID:"oolite-flightlog-main-map", title:"Flight Log", messageKey:"flightLog_header", overlay:{name:"fl-note_book.png", height:546}, exitScreen:"GUI_SCREEN_INTERFACES", choicesKey:"flightLog_choices"}, this.$choice);

	this.endPoint = this.flightArray.length;
	this.startPoint = this.endPoint - 10;

	let listCounter = 0; // reset the counter
	for(listCounter = this.startPoint; listCounter < this.endPoint; listCounter++) {
		if(this.flightArray[listCounter] >= 0) {
			mission.addMessageText((this.flightArray.length - listCounter) + " - " + System.systemNameForID(this.flightArray[listCounter]) + ", (" + this.killsArray[listCounter] + " kills,  " + this.creditsArray[listCounter] + "  cr).");
		}
		if(this.flightArray[listCounter] == -1) {
			mission.addMessageText((this.flightArray.length - listCounter) + " - Interstellar Space, (" + this.killsArray[listCounter] + " kills,  " + this.creditsArray[listCounter] + "  cr).");
		}
	}

	if(system.ID == -1) {
		mission.addMessageText("\nYou are currently in interstellar space (" + (player.score - this.baseKills) + " kills, " + (Math.floor(10 * (player.credits - this.baseCredits)) / 10) + "cr).");
	} else {
		mission.addMessageText("\nYou are currently in the " + system.name + " system in galaxy " + (galaxyNumber + 1) + " (" + (player.score - this.baseKills) + " kills, " + (Math.floor(10 * (player.credits - this.baseCredits)) / 10) + "cr).");
	}
}

this.$choice = function(choice)
	{
	switch(choice)
		{
		case "FLIGHTLOG_1_DUMP":
			{
			player.consoleMessage("Flight log written to latest.log", 6);
			log(this.name, "==================================");
			log(this.name, " ");

			let logCounter = 0 ; // reset the counter
			for(logCounter = 0;logCounter<this.flightArray.length;logCounter++)
				{
				if(this.flightArray[logCounter] >= 0)
					{
					log(this.name, (this.flightArray.length - logCounter) + " - " + System.systemNameForID(this.flightArray[logCounter]) + ", (" + this.killsArray[logCounter] + " kills,  " + this.creditsArray[logCounter] + "cr).");
					}
				if(this.flightArray[logCounter] == -1)
					{
					log(this.name, (this.flightArray.length - logCounter) + " - Interstellar Space, (" + this.killsArray[logCounter] + " kills,  " + this.creditsArray[logCounter] + "cr).");
					}
				}
			log(this.name, " ");
			if(system.ID != -1)
				{
				log(this.name, "Current system - " + system.name + " in galaxy " + (galaxyNumber + 1) + ", (" + (player.score - this.baseKills) + " kills, " + (Math.floor(10 * (player.credits - this.baseCredits)) / 10) + "cr).");
				}
			else
				{
				log(this.name, "Currently in interstellar space, (" + (player.score - this.baseKills) + " kills, " + (Math.floor(10 * (player.credits - this.baseCredits)) / 10) + "cr).");
				}
			log(this.name, "==================================");
			break;
			}

		case "FLIGHTLOG_2_RESET":
			{
			player.consoleMessage("Flight log cleared.", 6);
			this.playerEnteredNewGalaxy();
			break;
			}
		}
	}

this.shipWillExitWitchspace = function()
	{
	this.baseKills = player.score;
	this.baseCredits = player.credits;
	}

this.shipWillEnterWitchspace = function(cause)
	{
	this.kills = player.score - this.baseKills;
	this.profit = Math.floor(10 * (player.credits - this.baseCredits)) / 10;
	this.flightArray.push(system.ID);
	this.killsArray.push(this.kills);
	this.creditsArray.push(this.profit);

	this.$trimArrays();

	missionVariables.flightLogMemory = this.flightArray[0];
	missionVariables.flightKillsMemory = this.killsArray[0];
	missionVariables.flightCreditsMemory = this.creditsArray[0];

	let arrayCounter = 1 ; // set the counter
	for(arrayCounter = 1; arrayCounter < this.flightArray.length; arrayCounter++)
		{
		missionVariables.flightLogMemory = missionVariables.flightLogMemory + ":" + this.flightArray[arrayCounter];
		missionVariables.flightKillsMemory = missionVariables.flightKillsMemory + ":" + this.killsArray[arrayCounter];
		missionVariables.flightCreditsMemory = missionVariables.flightCreditsMemory + ":" + this.creditsArray[arrayCounter];
		}
	}

this.$trimArrays = function()
	{ // trim the arrays back to their original lengths by throwing out oldest (first in the array) log entries
	while(this.flightArray.length > this.maxLogLength)
		{ this.discard = this.flightArray.shift(); }

	while(this.killsArray.length > this.maxLogLength)
		{ this.discard = this.killsArray.shift(); }

	while(this.creditsArray.length > this.maxLogLength)
		{ this.discard = this.creditsArray.shift(); }
	}

this.playerEnteredNewGalaxy = function()
	{
	missionVariables.flightLogMemory = this.blankArray;
	missionVariables.flightKillsMemory = this.blankArray;
	missionVariables.flightCreditsMemory = this.blankArray;
	this.startUp();
	}