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

Expansion Commanders Log

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Adds a log of the last 100 major events in the current Commander's life, which can be dumped out to latest.log. The latest 10 are viewable in-game when docked. Adds a log of the last 100 major events in the current Commander's life, which can be dumped out to latest.log. The latest 10 are viewable in-game when docked.
Identifier oolite.oxp.Thargoid.CommandersLog oolite.oxp.Thargoid.CommandersLog
Title Commanders Log Commanders Log
Category Equipment Equipment
Author Thargoid Thargoid
Version 1.01 1.01
Tags equipment equipment
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Commanders_Log_OXP n/a
Download URL https://wiki.alioth.net/img_auth.php/3/32/Commanders_Log_1.00.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 1610873262

Documentation

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

Commanders Log v1.01 ReadMe & License.txt

Commanders Log OXP by Thargoid.

A little OXP by forum request of "Sendraks" and others to keep a log of the last 100 occasions where the Commander performed a landmark action or achievement. The most recent 15 can be viewed in-game, with the full list available via the latest.log dump.

The logged actions and achievements currently include:

* Purchase of a new ship.
* Galactic jump into a new galaxy.
* A witchspace mis-jump.
* Purchase of a maintenance overhaul (including location and cost).
* Attaining a new rank.

The recent list is accessible via the F4 screen when docked (just select Commander's Log), and from there can either be reset or the full log dumped out to the latest.log file for further manipulation or storage.

This OXP is based on (and is a variant of) my existing Flight Log OXP. Both will work quite happily together, but are independent of each other.

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 :)

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

Instructions:

For those who have downloaded the OXP version, unzip the file, and then move the folder "Commanders Log 1.01.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:

10/02/2014 - Version 1.00, initial release.
07/08/2014 - Version 1.01, adjusted the script to run on startUpComplete rather than startUp, to allow for saves at non-main stations.

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

Acknowledgements:

With thanks to Sendraks for the original inspiration, and to Diogenese Senna, Cody and Diziet Sma for idea inputs.

Also thanks to Neelix for the heads-up about the save at non-main station glitch and fix suggestion.

Equipment

This expansion declares no equipment.

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Config/script.js
this.name					= "commandersLog";
this.author					= "Thargoid";
this.copyright				= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description			= "Saves a list of significant events to the Commander";
this.version				= "1.01";

this.startUpComplete = function()
	{
	if(!missionVariables.commandersLogText) // if this is the first run of the OXP
		{ missionVariables.commandersLogText = "Log system first initialised"; }
	
	if(!missionVariables.commandersLogDate) // if this is the first run of the OXP
		{ missionVariables.commandersLogDate = clock.days + ":" + clock.hoursComponent + ":" + clock.minutesComponent + ":" + clock.secondsComponent; }

	this.textArray = missionVariables.commandersLogText.split(",");
	this.dateArray = missionVariables.commandersLogDate.split(",");

	this.oldRank = player.rank;
	this.oldCredits = player.credits;

	this.maxLogSize = 100; // set how max number of entries to store
	this.setInterface();
	}

this.shipDockedWithStation = function()
	{
	this.setInterface();
	this.playerWillSaveGame();
	}

this.playerWillSaveGame = function()
	{ 
	missionVariables.commandersLogText = this.textArray;
	missionVariables.commandersLogDate = this.dateArray;
	}

this.setInterface = function()
	{
	player.ship.dockedStation.setInterface("CommandersLog",
		{ title: "Commander's Log",
		category: "Logs",
		summary: "Displays the Commander's ship purchase and galactic jump history.",
		callback: this.$showLog.bind(this) });
	}	
	
this.$showLog = function()
	{
	mission.runScreen({title:"Commander's Log", messageKey:"commandersLog_header", choicesKey:"commandersLog_choices"}, this.choice);
	this.startPoint = 0;
	this.endPoint = this.textArray.length;
	if(this.endPoint > 14)
		{this.startPoint = this.endPoint - 15;}
	let listCounter = 0; // reset the counter
	for(listCounter = this.startPoint; listCounter < this.endPoint; listCounter++)
		{ mission.addMessageText(this.dateArray[listCounter] + " - " + this.textArray[listCounter]); }
	}

this.choice = function(choice)
	{
	switch(choice)
		{
		case "COMMANDERSLOG_1_DUMP":
			{
			player.consoleMessage("Commanders log written to latest.log", 6);
			log(this.name, "==========================================================");
			log(this.name, " ");
			
			let logCounter = 0 ; // reset the counter
			for(logCounter = 0;logCounter<this.dateArray.length;logCounter++)
				{ log(this.name, (this.dateArray[logCounter] + " - " + this.textArray[logCounter])); }
			log(this.name, " ");
			log(this.name, "==========================================================");
			break;
			}

			case "COMMANDERSLOG_2_RESET":
			{
			delete this.textArray;
			delete this.dateArray;
			this.textArray = new Array;
			this.dateArray = new Array;
			this.textArray[0] = "Commanders log reset";
			this.dateArray[0] = clock.days + ":" + clock.hoursComponent + ":" + clock.minutesComponent + ":" + clock.secondsComponent; 
			player.consoleMessage("Commander's log reset.", 6);
			this.playerWillSaveGame();
			break;
			}
		}
	}
	
this.playerEnteredNewGalaxy = function(galaxyNumber)
	{
	this.galaxyNumber = (galaxyNumber * 1 ) + 1;
	this.clockString = clock.days + ":" + clock.hoursComponent + ":" + clock.minutesComponent + ":" + clock.secondsComponent; 
	this.dateArray.push(this.clockString);
	this.textArray.push("Ship jumped to galaxy " + this.galaxyNumber);
	this.trimArrays();
	}
	
this.playerBoughtNewShip = function(ship)
	{
	this.clockString = clock.days + ":" + clock.hoursComponent + ":" + clock.minutesComponent + ":" + clock.secondsComponent; 
	this.dateArray.push(this.clockString);
	this.firstLetter = ship.name.charAt(0).toLowerCase();
	this.vowels = "aeiou";
	if(this.vowels.indexOf(this.firstLetter))
		{ this.prefix = "a ";}
	else
		{this.prefix = "an ";}
	this.textArray.push("Commander purchased "+ this.prefix + ship.name);
	this.trimArrays();
	}
	
this.shipWillExitWitchspace = function()
	{
	if(system.ID === -1)
		{
		this.clockString = clock.days + ":" + clock.hoursComponent + ":" + clock.minutesComponent + ":" + clock.secondsComponent; 
		this.dateArray.push(this.clockString);
		this.textArray.push("Witchspace misjump occurred");
		this.trimArrays();
		}
	}

this.guiScreenChanged = function(to, from)
	{
	if(to && to === "GUI_SCREEN_EQUIP_SHIP")
		{ this.oldCredits = player.credits; }
	}
	
this.playerBoughtEquipment = function(equip)
	{
	if(equip && equip == "EQ_RENOVATION")
		{	
		this.clockString = clock.days + ":" + clock.hoursComponent + ":" + clock.minutesComponent + ":" + clock.secondsComponent; 
		this.dateArray.push(this.clockString);
		this.textArray.push("Maintenance overhaul purchased at " + system.name + " for " + (this.oldCredits - player.credits) + "cr");
		this.trimArrays();
		}
	this.oldCredits = player.credits;	
	}
	
this.shipKilledOther = function(whom, damageType)
	{
	if(player.rank !== this.oldRank)
		{
		this.clockString = clock.days + ":" + clock.hoursComponent + ":" + clock.minutesComponent + ":" + clock.secondsComponent; 
		this.dateArray.push(this.clockString);
		this.textArray.push("Rank of " + player.rank + " achieved");
		this.trimArrays();
		}
	this.oldRank = player.rank;
	}
	
this.trimArrays = function()
	{
	if(this.dateArray[0] === "" || this.dateArray.length > this.maxLogSize) // remove the first empty item if present after adding first entry, or if array is too large
		{
		this.dateArray.shift();
		this.textArray.shift();
		}
	}