Scripts/oolite-registership.js |
"use strict";
this.name = "oolite-registership";
this.author = "cim, spara";
this.startUp = this.shipWillExitWitchspace = function()
{
if (system.mainStation)
{
system.mainStation.setInterface("oolite-registership",{
title: expandMissionText("oolite-registership-interface-title"),
category: expandMissionText("oolite-registership-interface-category"),
summary: expandMissionText("oolite-registership-interface-summary"),
callback: this._registerShip.bind(this)
});
}
}
this._registerShip = function() {
mission.runScreen({
titleKey: "registership-ext1-title",
messageKey: "registership-ext1",
screenID: "oolite-register",
background: "random_player_bg.png",
choicesKey: "registership-ext1-options"
},
function (choice) {
if (choice === "1_RANDOM") this._registerShipRandomPilot();
else if (choice === "2_ENTER") this._registerShipEnterPilot();
else this._registerShip2();
}
);
}
this._registerShipRandomPilot = function() {
var firstNameSources = ["%N", "[random_player_first_name]"];
var secondNameSources = ["[nom]", "[random_player_second_name]"];
var firstNameSource = firstNameSources[Math.floor(Math.random() * firstNameSources.length)];
var secondNameSource = secondNameSources[Math.floor(Math.random() * secondNameSources.length)];
var randomName = global.expandDescription(firstNameSource + " " + secondNameSource);
mission.runScreen({
titleKey: "registership-ext2-title",
message: global.expandMissionText("registership-ext2") + randomName + ".",
screenID: "oolite-register",
background: "random_player_bg.png",
choicesKey: "registership-ext2-options"
},
function (choice) {
if (choice === "1_RANDOM") this._registerShipRandomPilot();
else if (choice === "2_ACCEPT") this._registerShip2(randomName);
else this._registerShip2();
}
);
}
this._registerShipEnterPilot = function() {
mission.runScreen({
titleKey: "registership-ext3-title",
messageKey: "registership-ext3",
screenID: "oolite-register",
background: "random_player_bg.png",
textEntry: true
},this._registerShip2.bind(this));
}
this._registerShip2 = function(cdrname)
{
if (cdrname && cdrname != "")
{
player.name = cdrname;
}
mission.runScreen({
titleKey: "registership-ext4-title",
messageKey: "registership-ext4",
screenID: "oolite-register",
background: "random_player_bg.png",
choicesKey: "registership-ext1-options"
},
function (choice) {
if (choice === "1_RANDOM") this._registerShipRandomShip();
else if (choice === "2_ENTER") this._registerShipEnterShip();
else this._registerShip3();
}
);
}
this._registerShipRandomShip = function() {
var sources = ["random_player"];
if (worldScripts["randomshipnames"]) {
sources.push("trader");
sources.push("hunter");
sources.push("pirate");
}
var source = sources[Math.floor(Math.random() * sources.length)];
if (source === "trader")
var randomShipName = worldScripts["randomshipnames"].$randomTraderName(player.ship);
else if (source === "hunter")
var randomShipName = worldScripts["randomshipnames"].$randomHunterName(player.ship);
else if (source === "pirate")
var randomShipName = worldScripts["randomshipnames"].$randomPirateName(player.ship);
else
var randomShipName = global.expandDescription("[random_player_shipname]");
mission.runScreen({
titleKey: "registership-ext5-title",
message: global.expandMissionText("registership-ext5") + randomShipName + ".",
screenID: "oolite-register",
background: "random_player_bg.png",
choicesKey: "registership-ext2-options"
},
function (choice) {
if (choice === "1_RANDOM") this._registerShipRandomShip();
else if (choice === "2_ACCEPT") this._registerShip3(randomShipName);
else this._registerShip3();
}
);
}
this._registerShipEnterShip = function() {
mission.runScreen({
titleKey: "registership-ext7-title",
messageKey: "registership-ext7",
screenID: "oolite-register",
background: "random_player_bg.png",
textEntry: true
},this._registerShip3.bind(this));
}
this._registerShip3 = function(shipname)
{
if (shipname && shipname != "")
{
player.ship.shipUniqueName = shipname;
}
mission.runScreen({
titleKey: "oolite-registership-title-part3",
messageKey: "oolite-registership-instructions-part3",
screenID: "oolite-register",
exitScreen: "GUI_SCREEN_INTERFACES",
background: "random_player_bg.png"
});
mission.addMessageText(global.expandMissionText("registership-ext6"));
}
|