Page 1 of 2
Limit equipment for a vessel
Posted: Sun Mar 09, 2025 1:14 pm
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?
Re: Limit equipment for a vessel
Posted: Sun Mar 09, 2025 4:46 pm
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.
Re: Limit equipment for a vessel
Posted: Mon Mar 10, 2025 8:13 am
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.
Re: Limit equipment for a vessel
Posted: Mon Mar 10, 2025 8:50 am
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:-
- is actually physically smaller than a pulse laser, which uses a linear laser multiplier:-
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.
Sorry, Greenlanders.
I would direct this question to
another_commander, who might know of a less-used shipdata key that does what you want.
Re: Limit equipment for a vessel
Posted: Mon Mar 10, 2025 5:27 pm
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.
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).
Re: Limit equipment for a vessel
Posted: Mon Mar 10, 2025 5:43 pm
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?
Re: Limit equipment for a vessel
Posted: Tue Mar 11, 2025 5:51 pm
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.
Re: Limit equipment for a vessel
Posted: Tue Mar 11, 2025 7:29 pm
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.
Re: Limit equipment for a vessel
Posted: Sat Mar 15, 2025 5:59 am
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.
Re: Limit equipment for a vessel
Posted: Sat Mar 15, 2025 8:23 am
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!
Re: Limit equipment for a vessel
Posted: Sat Mar 15, 2025 8:50 pm
by phkb
Ah! And here I was thinking I had something unique to contribute. Ah well. Such is life.
Re: Limit equipment for a vessel
Posted: Sat Mar 15, 2025 9:08 pm
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.
Re: Limit equipment for a vessel
Posted: Sat Mar 29, 2025 12:35 pm
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.
Re: Limit equipment for a vessel
Posted: Sat Mar 29, 2025 12:51 pm
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";
Re: Limit equipment for a vessel
Posted: Sat Mar 29, 2025 2:05 pm
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";