Scripts/tp_conditions.js |
// conditions for award of Teleportation Drive
"use strict";
this.name = "TP Conditions";
this.author = "Reval";
this.licence = "CC BY-NC-SA 4.0";
this.version = "1.0";
this.allowAwardEquipment = function(equipment, ship, context) {
if (equipment == "EQ_TP_DRIVE")
if ((player.ship.equipmentStatus ("EQ_ADVANCED_COMPASS") === "EQUIPMENT_OK") && (player.ship.equipmentStatus ("EQ_FUEL_INJECTION") === "EQUIPMENT_OK"))
return true; else return false;
if (equipment == "EQ_TP_DRIVE_REM")
if (player.ship.equipmentStatus ("EQ_TP_DRIVE") === "EQUIPMENT_OK")
return true; else return false;
return true;
}
|
Scripts/tp_script.js |
"use strict"
this.name = "Teleportation Drive";
this.author = "Reval";
this.license = "CC-BY-NC-SA 4.0";
this.version = "1.2";
this.description = "FE Shipyards will link your ASC and Injector circuitry to the Hyperspace motor, allowing the formation of a miniature wormhole between the ship and its destination station. With a tap of the 'i' button, space is folded and transport is instantaneous. We call it the T-drive.";
this.startUp = function() {
this.$tpLastDest = player.ship.position;
// is T-drive installed?
this.$tpHasEq = false;
// has compass target changed?
this.$tpChanged = false;
// drive name (changeable via 'poll')
this.$tpDriveName = "T-drive";
}
this.playerWillSaveGame = function() {
// save preferred drive name
missionVariables.tpDriveName = this.$tpDriveName;
}
this.startUPComplete = function() {
// load preferred drive name
if (missionVariables.tpDriveName != null)
this.$tpDriveName = missionVariables.tpDriveName;
// prepare name poll options
var sta = player.ship.dockedStation;
if (ps.equipmentStatus ("EQ_TP_DRIVE") === "EQUIPMENT_OK")
this._tpPrepPoll(sta);
}
this.shipDockedWithStation = function(station) {
// prepare Name Poll Interface
var ps=player.ship;
if (ps.equipmentStatus ("EQ_TP_DRIVE") === "EQUIPMENT_OK")
this._tpPrepPoll(station);
}
this.shipWillLaunchFromStation = function() {
// establish once whether ship has the T-drive
this.$tpHasEq = (player.ship.equipmentStatus ("EQ_TP_DRIVE") === "EQUIPMENT_OK");
if (this.$tpHasEq) {
// set up 'destination monitor'
if(!this.$tpTimer) this.$tpTimer=new Timer(this,this._tpMonitorDestination.bind(this),0,0.25);
// set up 'injectors' monitor
if(!this.$tpTimer2) this.$tpTimer2=new Timer(this,this._tpMonitorInjectors.bind(this),0,0.25);
this.$tpChanged = false;
}
}
this.playerBoughtEquipment = function(equipment, paid) {
var pc = player.consoleMessage;
var ps = player.ship;
if (equipment == "EQ_TP_DRIVE") {
pc("Re-routing H-circuits for T-drive.",9);
pc("Teleportation Drive is operative.",9);
// decicredits, so convert
this.$tpCost = paid/10;
// prepare name poll options
var sta = player.ship.dockedStation;
if (ps.equipmentStatus ("EQ_TP_DRIVE") === "EQUIPMENT_OK")
this._tpPrepPoll(sta);
}
if (equipment == "EQ_TP_DRIVE_REM") {
ps.removeEquipment("EQ_TP_DRIVE");
ps.removeEquipment("EQ_TP_DRIVE_REM");
pc("Teleportation Drive removed.",9);
player.credits += this.$tpCost;
pc(this.$tpCost + "cr refunded.",9);
}
}
// ASC compass target monitor
this._tpMonitorDestination = function() {
if (this.$tpHasEq) {
try {
var pc = player.consoleMessage;
var ps = player.ship;
if (ps.compassTarget != null)
var psd = ps.compassTarget;
else var psd = this.$tpLastDest;
var psdn = psd.displayName;
var last = this.$tpLastDest;
// if destination changed, note it
if ((last != psd) && (psd)) {
this.$tpChanged = true;
var c = ps.messageGuiTextColor;
ps.messageGuiTextColor = "purpleColor";
pc("TP: "+psdn,7);
this.$tpLastDest = psd;
ps.messageGuiTextColor = c;
}
} finally {}
}
}
// injectors status monitor
this._tpMonitorInjectors = function() {
if (this.$tpHasEq) {
var ps = player.ship;
var pc = player.consoleMessage;
if (this.$tpChanged)
if (ps.injectorsEngaged) {
this.$tpChanged = false;
// report drive start
var c = ps.messageGuiTextColor;
ps.messageGuiTextColor = "purpleColor";
pc(this.$tpDriveName+" engaged.",9);
// Teleport
ps.position = ps.compassTarget.position;
// report arrival
pc("Arrived at "+ps.compassTarget.displayName,9);
ps.messageGuiTextColor = c;
}
}
}
// create Teleportation Drive name poll
this._tpPrepPoll = function(station) {
station.setInterface("tpPoll",{
title: "FE Shipyards Teleportation Drive name poll",
category: "Your FE Shipyards",
summary: "FE Shipyards gives you the option of changing the short name of your Teleportation Drive." ,
callback: this._tpShowPoll.bind(this)
});
}
// show Teleportation Drive name poll
this._tpShowPoll = function() {
var parameters = new Object();
parameters.title = "FE Shipyards Customer Survey";
parameters.message = "\n\nWhat would you like the short utility name for the Teleportation Drive to be? \n\n";
parameters.choicesKey = "tpChoice";
mission.runScreen(parameters, callback);
function callback(choice) {
if (choice === "1. T-drive") this.$tpDriveName = "T-drive"; else
if (choice === "2. Tau-drive") this.$tpDriveName = "Tau-drive"; else
if (choice === "3. Mu-drive") this.$tpDriveName = "Mu-drive"; else
if (choice === "4. GET-drive") this.$tpDriveName = "GET-drive"; else
if (choice === "5. Ooh-drive") this.$tpDriveName = "Ooh-drive"; else
if (choice === "6. Moolah-drive") this.$tpDriveName = "Moolah-drive";
player.commsMessage("Thank you for your input. "+this.$tpDriveName+" it is!",7);
}
}
|