Limit equipment for a vessel

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

Moderators: winston, another_commander

User avatar
DavidKroc
Competent
Competent
Posts: 39
Joined: Thu Jan 02, 2025 10:20 am
Location: Onrira Orbital Shipyards
Contact:

Limit equipment for a vessel

Post by DavidKroc »

Hello,

I'm trying to find out if there is a mechanism in shipyard.plist or shipdata.plist to prevent the purchase of standard equipment, a bit like what incompatible_with_equipment does in equipment.plist.

My idea is to prevent the Sidewinder NG from being fitted with a military laser (for example) because there isn't enough room in such a small vessel to mount it.

How can I do that?

Do I have to create a "virtual" equipment, equip by default all Sidewinder NG with it and list all wanted forbidden equipment as incompatible_with_equipment or is there a more elegant way?
User avatar
Nite Owl
---- E L I T E ----
---- E L I T E ----
Posts: 574
Joined: Sat Jan 20, 2018 4:08 pm
Location: In The Dark

Re: Limit equipment for a vessel

Post by Nite Owl »

You have already done this with several pieces of equipment in your shipyard.plist for this ship. The equipment you have commented out ( // preceding the item) in the optional_equipment section of the code will prevent your ship from being able to purchase that equipment. Alternatively you could simply not include the commented out items by deleting them from the array. Do the same with the Military Laser and it will not be available for your ship.

Edit
Yikes !!
Ignore this post as the next one in the thread proves me wrong. Went looking for an answer and misinterpreted what was read.
Last edited by Nite Owl on Mon Mar 10, 2025 7:10 pm, edited 1 time in total.
Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2579
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Limit equipment for a vessel

Post by Wildeblood »

Nite Owl wrote: Sun Mar 09, 2025 4:46 pm
You have already done this with several pieces of equipment in your shipyard.plist for this ship. The equipment you have commented out ( // preceding the item) in the optional_equipment section of the code will prevent your ship from being able to purchase that equipment. Alternatively you could simply not include the commented out items by deleting them from the array. Do the same with the Military Laser and it will not be available for your ship.
That can't be right, or no OXP equipment would work. The optional_equipment field in shipyard.plist controls what could be found already installed on ships for sale in a shipyard, but doesn't affect players later purchasing equipment.
"There are large, white swans, and there are small, black swans," he explained, "But there are no medium-sized swans, and there are no grey swans. The non-existence of grey swans mitigates against belief in Mr Darwin's theory."
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2579
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Limit equipment for a vessel

Post by Wildeblood »

DavidKroc wrote: Sun Mar 09, 2025 1:14 pm
I'm trying to find out if there is a mechanism in shipyard.plist or shipdata.plist to prevent the purchase of standard equipment, a bit like what incompatible_with_equipment does in equipment.plist.
That somewhat goes against the spirit of the game; there's a clue in the phrase "standard equipment".
DavidKroc wrote: Sun Mar 09, 2025 1:14 pm
My idea is to prevent the Sidewinder NG from being fitted with a military laser (for example) because there isn't enough room in such a small vessel to mount it.
Ah, now that is based on a mistaken premise. As you can clearly see here, a military laser, which uses a spherical laser multiplier:-

Image

- is actually physically smaller than a pulse laser, which uses a linear laser multiplier:-

Image
DavidKroc wrote: Sun Mar 09, 2025 1:14 pm
How can I do that?

Do I have to create a "virtual" equipment, equip by default all Sidewinder NG with it and list all wanted forbidden equipment as incompatible_with_equipment or is there a more elegant way?
I can think of another way, which is to use an equipment over-ride to attach a condition script to the military laser, but that is not more elegant. What you suggest should work, so I'm certain it can be done, one way or another. :twisted: Sorry, Greenlanders.

I would direct this question to another_commander, who might know of a less-used shipdata key that does what you want.
"There are large, white swans, and there are small, black swans," he explained, "But there are no medium-sized swans, and there are no grey swans. The non-existence of grey swans mitigates against belief in Mr Darwin's theory."
User avatar
DavidKroc
Competent
Competent
Posts: 39
Joined: Thu Jan 02, 2025 10:20 am
Location: Onrira Orbital Shipyards
Contact:

Re: Limit equipment for a vessel

Post by DavidKroc »

I don't know where these images come from and if they can be considered as proof, but I still have the impression that the military laser is closer to the ceiling (therefore bigger) than the beam laser. But never mind. :D

I've tried my virtual equipment idea and so far it's not working. In fact, incompatible_with_equipment doesn't seem to work at all in Oolite 1.90 (I'll have to look into this).
User avatar
Cholmondely
Archivist
Archivist
Posts: 5663
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Limit equipment for a vessel

Post by Cholmondely »

DavidKroc wrote: Mon Mar 10, 2025 5:27 pm
I don't know where these images come from...
The Wildebloodian prodding of AI, meseems.

Nevermind. What else would you really like to do to your OXP?
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
DavidKroc
Competent
Competent
Posts: 39
Joined: Thu Jan 02, 2025 10:20 am
Location: Onrira Orbital Shipyards
Contact:

Re: Limit equipment for a vessel

Post by DavidKroc »

Cholmondely wrote: Mon Mar 10, 2025 5:43 pm
What else would you really like to do to your OXP?
As the Sidewinder NG is very small (21 x 4 x 15 m) for 11,500 kg, this means very little free space inside (especially since Spalder and Starblaze had to add a Witchdrive inside). My idea was therefore to prohibit the installation of big standard equipments from vanilla game or most popular OXPs.

This include :
  • Fuel Scoops
  • ExtraFuelTanks
  • Fuel Collector
  • Repair Bots
  • Retro Rockets
  • Shield Equalizer And Capacitors
  • Shield Cycler
  • Teleportation Drive
I'm not sure about the Escape pod (but as it is fitted such that it completely encloses the flight deck, it might be possible to add it) and the list of laser / News Lasers to forbid because they couldn't fit into the same slot as the standard beam laser.
User avatar
Cholmondely
Archivist
Archivist
Posts: 5663
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Limit equipment for a vessel

Post by Cholmondely »

DavidKroc wrote: Tue Mar 11, 2025 5:51 pm
Cholmondely wrote: Mon Mar 10, 2025 5:43 pm
What else would you really like to do to your OXP?
As the Sidewinder NG is very small (21 x 4 x 15 m) for 11,500 kg, this means very little free space inside (especially since Spalder and Starblaze had to add a Witchdrive inside). My idea was therefore to prohibit the installation of big standard equipments from vanilla game or most popular OXPs.

This include :
  • Fuel Scoops
  • ExtraFuelTanks
  • Fuel Collector
  • Repair Bots
  • Retro Rockets
  • Shield Equalizer And Capacitors
  • Shield Cycler
  • Teleportation Drive
I'm not sure about the Escape pod (but as it is fitted such that it completely encloses the flight deck, it might be possible to add it) and the list of laser / News Lasers to forbid because they couldn't fit into the same slot as the standard beam laser.
Fuel Scoops are almost a necessity for the Stranger's World variant of Oolite. And they usually fit "outside" the ship with alterations to the cargo bay "inside", if I understand correctly. With no cargo bay, they would only act as fuel scoops, not cargo scoops, so most of those alterations become irrelevant.

And do Fuel Collector and Repair Bots even work if one has no cargo bay? They might not even be purchasable anyways.
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4888
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Limit equipment for a vessel

Post by phkb »

There are a few existing mods that limit the equipment in some way.

- Ship Configuration (by me, shameless plug) implements the idea of each ship having a different amount of space available for installing equipment.
- Telescope Extender (by Norby) has equipment that is limited to ships of a certain size. Same for Towbar.

In most cases, they are setting the condition_script property of the equipment, and doing the check in that code for whether the equipment can be installed. As you'd be working with existing equipment, you'd need to utilise the equipment-overrides.plist file so you could apply your condition_script to them.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2579
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Limit equipment for a vessel

Post by Wildeblood »

phkb wrote: Sat Mar 15, 2025 5:59 am
In most cases, they are setting the condition_script property of the equipment, and doing the check in that code for whether the equipment can be installed. As you'd be working with existing equipment, you'd need to utilise the equipment-overrides.plist file so you could apply your condition_script to them.
That's what I said!
"There are large, white swans, and there are small, black swans," he explained, "But there are no medium-sized swans, and there are no grey swans. The non-existence of grey swans mitigates against belief in Mr Darwin's theory."
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4888
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Limit equipment for a vessel

Post by phkb »

Wildeblood wrote: Sat Mar 15, 2025 8:23 am
That's what I said!
Ah! And here I was thinking I had something unique to contribute. Ah well. Such is life.
User avatar
DavidKroc
Competent
Competent
Posts: 39
Joined: Thu Jan 02, 2025 10:20 am
Location: Onrira Orbital Shipyards
Contact:

Re: Limit equipment for a vessel

Post by DavidKroc »

I'm going to drop this idea. Bulky equipment already uses cargo space (and the Sidewinder NG has none, so it can't install them) and some others require a minimum ship weight to install them. I'll settle for that.
User avatar
DavidKroc
Competent
Competent
Posts: 39
Joined: Thu Jan 02, 2025 10:20 am
Location: Onrira Orbital Shipyards
Contact:

Re: Limit equipment for a vessel

Post by DavidKroc »

Even if I dropped this idea for the moment, I kept on working on this and discovered incompatible_with_equipment is completely ignored by Oolite.

So I chose another option: include an Equipment-overrides.plist file in the OXP and block unwanted equipment with a condition_script.

Here's the sample content of Equipment-overrides.plist:

Code: Select all

{
  "EQ_ESCAPE_POD" = {
  	condition_script = "equip_conditions.js";
  };
  "EQ_FUEL_SCOOPS" = {
  	condition_script = "equip_conditions.js";
  };
}
And here's the content of equip_conditions.js (based on the condition script in RedSpear new_lasers):

Code: Select all

this.name        = "equip_conditions";
this.description = "conditions for Sidewinder NG";

"use strict";

this.allowAwardEquipment = function(equipment, ship, context) // **changed by phkb - credit and thanks to him.
{
	if (ship.shipClassName == "Sidewinder NG" && equipment == "EQ_FUEL_SCOOPS")
	{
		//log(this.name, "FUEL_SCOOPS BLOCKED");
		return false;
	}
	if (ship.shipClassName == "Sidewinder NG" && equipment == "EQ_ESCAPE_POD")
	{
		return false;
	}

	// remainder from oolite-conditions.js

	// OXP hook to allow stations to forbid specific equipment
	if (context == "purchase" && player.ship.dockedStation && player.ship.dockedStation.scriptInfo["oolite-barred-equipment"])
	{
		if (player.ship.dockedStation.scriptInfo["oolite-barred-equipment"].indexOf(equipment) != -1)
		{
			return false;
		}
	}

	// OXP hook to allow ships to forbid specific "available to all" equipment
	if (ship.scriptInfo && ship.scriptInfo["oolite-barred-equipment"] && ship.scriptInfo["oolite-barred-equipment"].indexOf(equipment) != -1)
	{
		return false;
	}

	// otherwise allowed
	return true;
}
According to the tests I've carried out, it works correctly.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2579
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Limit equipment for a vessel

Post by Wildeblood »

DavidKroc wrote: Sat Mar 29, 2025 12:35 pm
So I chose another option: include an Equipment-overrides.plist file in the OXP and block unwanted equipment with a condition_script.
That sounds familiar.
condition_script = "equip_conditions.js";
Choose a less obvious filename, please, DK.

condition_script = "dk_equip_conditions.js";
"There are large, white swans, and there are small, black swans," he explained, "But there are no medium-sized swans, and there are no grey swans. The non-existence of grey swans mitigates against belief in Mr Darwin's theory."
User avatar
DavidKroc
Competent
Competent
Posts: 39
Joined: Thu Jan 02, 2025 10:20 am
Location: Onrira Orbital Shipyards
Contact:

Re: Limit equipment for a vessel

Post by DavidKroc »

Wildeblood wrote: Sat Mar 29, 2025 12:51 pm
Choose a less obvious filename, please, DK.
Good advice. Thanks.

Done:
condition_script = "davidkroc_equip_cond.js";
Post Reply