Page 1 of 1

Player Ship Naming by Ship Type - Help?

Posted: Sat Oct 20, 2012 7:59 am
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?

Re: Player Ship Naming by Ship Type - Help?

Posted: Tue Oct 23, 2012 4:54 am
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;
	}

Re: Player Ship Naming by Ship Type - Help?

Posted: Thu Nov 01, 2012 6:11 am
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!