Player Ship Naming by Ship Type - Help?

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

Post Reply
User avatar
Ranthe
---- E L I T E ----
---- E L I T E ----
Posts: 330
Joined: Sat Oct 13, 2012 7:35 pm
Location: Paraparaumu, New Zealand (TL 8, Rich Agricultural, Multi-Government)

Player Ship Naming by Ship Type - Help?

Post by Ranthe »

I've been sampling some of the various HUDs in the OXP list, and one HUD I like is the Wide-Screen HUD - in particular, the ability to edit the OXP to display your own ship's name on the screen. I find it adds to ambience to have something in the game that reflect the name you've chosen for your ship.

What I'm interested in however is whether it's possible, and if so how to go about, having ship-type specific coding for the name display for people who fly multiple ships and missions. In other words, is is possible to display the ship name "Roj Blake" for a Boa 2 Class Cruiser and "Atomic Annie" for your Anaconda without having to edit and reload the HUD OXP?

From looking at other OXPs, I think you can do it with "player-<shiptype>", but I don't know how this works. Any suggestions?
Commander Ranthe: Flying the Anaconda-class transport Atomic Annie through Galaxy 2.
Combat Ranking: Dangerous
"Big ships take more booty on your interstellar flights..."
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2286
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Player Ship Naming by Ship Type - Help?

Post by Wildeblood »

Ranthe wrote:
I've been sampling some of the various HUDs in the OXP list, and one HUD I like is the Wide-Screen HUD - in particular, the ability to edit the OXP to display your own ship's name on the screen. I find it adds to ambience to have something in the game that reflect the name you've chosen for your ship.

What I'm interested in however is whether it's possible, and if so how to go about, having ship-type specific coding for the name display for people who fly multiple ships and missions. In other words, is is possible to display the ship name "Roj Blake" for a Boa 2 Class Cruiser and "Atomic Annie" for your Anaconda without having to edit and reload the HUD OXP?

From looking at other OXPs, I think you can do it with "player-<shiptype>", but I don't know how this works. Any suggestions?
If you're using the development versions (1.77) of Oolite, then yes, you could add several labels to one HUD file and a script that selects the right one automatically using player.ship.name. Have a look in the 1.77 version of Wide-Screen HUD, where the compass is labelled with its current mode, for an example of how to do it. Wide-Screen HUD is the first publicly-available HUD OXP to use this feature. However that's probably unnecessary complication in most cases.

Easier, and compatible with Oolite 1.76, is to duplicate the whole hud.plist file, making whatever changes you want, so you have two to select from - say roj-hud.plist and annie-hud.plist - then define one as the current HUD to use in flight. Open script.js in Wide-Screen HUD OXP, and you'll find this section, where the in-flight HUD to use is selected and stored in a variable (this.wa_flightHUD) for later use:-

Code: Select all

/* ==============================
			VERSION CHECK AT START-UP
==================================== */

this.startUp = function()
	{
	if (0 < oolite.compareVersion("1.77"))
		{
		// Oolite version is older than 1.77...
		this.wa_flightHUD = "wide-screen-hud.plist";
		log(this.name,"Wide-screen HUD for Oolite version 1.76 selected.");
		}
	else
		{
		this.wa_flightHUD = "wide-screen-177-hud.plist";
		log(this.name,"Wide-screen HUD for Oolite development version 1.77 selected.");
		}
	player.ship.hud = this.wa_flightHUD;
	}

Replace that with a check for ship name instead:-

Code: Select all

/* ==============================
		SHIP NAME CHECK AT START-UP
==================================== */

this.startUp = function()
	{
	if (player.ship.name === "Anaconda")
		{
		this.wa_flightHUD = "annie-wide-screen-hud.plist";
		}
	else if (player.ship.name === "Boa")
		{
		this.wa_flightHUD = "roj-wide-screen-hud.plist";
		}
	else
		{
		this.wa_flightHUD = "wide-screen-hud.plist";
		}
	player.ship.hud = this.wa_flightHUD;
	}
User avatar
Ranthe
---- E L I T E ----
---- E L I T E ----
Posts: 330
Joined: Sat Oct 13, 2012 7:35 pm
Location: Paraparaumu, New Zealand (TL 8, Rich Agricultural, Multi-Government)

Re: Player Ship Naming by Ship Type - Help?

Post by Ranthe »

Thanks for that - I'm running v1.76 so I'll try the multi HUD plist approach.

EDIT: Yay! It works! I edited "Boa" to "Boa Class Cruiser" and everything displays as expected.
Thanks very much for this!
Commander Ranthe: Flying the Anaconda-class transport Atomic Annie through Galaxy 2.
Combat Ranking: Dangerous
"Big ships take more booty on your interstellar flights..."
Post Reply