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

Expansion Random Player/Ship Name

Content

Warnings

  1. Information URL mismatch between OXP Manifest and Expansion Manager string length at character position 0

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Add random pilot and random ship names to the ship registration interface. More variation to random ship names can be added with Random Ship Names OXP. Add random pilot and random ship names to the ship registration interface. More variation to random ship names can be added with Random Ship Names OXP.
Identifier oolite.oxp.spara.random_player-ship_name oolite.oxp.spara.random_player-ship_name
Title Random Player/Ship Name Random Player/Ship Name
Category Ambiance Ambiance
Author spara spara
Version 1.0.1 1.0.1
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL n/a
Download URL https://wiki.alioth.net/img_auth.php/2/2f/Random_player_1.0.1.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1610873261

Documentation

Also read http://wiki.alioth.net/index.php/Random%20Player/Ship%20Name

Equipment

This expansion declares no equipment. This may be related to warnings.

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
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"));
}