Equipment-overrides :-/
Moderators: winston, another_commander
- Killer Wolf
- ---- E L I T E ----
- Posts: 2278
- Joined: Tue Jan 02, 2007 12:38 pm
Equipment-overrides :-/
Struggling w/ this [and everything else, lol].
wiki says its entries override the normal equipment plist, so i've taken the stock equipment plist, renamed it and tweaked prices. docked at my station, nothing. log says
"[plist.wrongType]: Property list is wrong type - expected NSDictionary, got GSArray."
which i seems to be due to this plist, though it doesn't say specifically ~ when i changed something i got a different error then got the error back when i reverted. Not sure why i'd get it when i copied the stock plist though, wiki doesn't seem to suggest i need other entries?
tried docking at the main station in case there was some quirk w/ my own but it's the same standard list there.
TIA
wiki says its entries override the normal equipment plist, so i've taken the stock equipment plist, renamed it and tweaked prices. docked at my station, nothing. log says
"[plist.wrongType]: Property list is wrong type - expected NSDictionary, got GSArray."
which i seems to be due to this plist, though it doesn't say specifically ~ when i changed something i got a different error then got the error back when i reverted. Not sure why i'd get it when i copied the stock plist though, wiki doesn't seem to suggest i need other entries?
tried docking at the main station in case there was some quirk w/ my own but it's the same standard list there.
TIA
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Equipment-overrides :-/
The format of the equipment-overrides.plist is slightly different to the equipment.plist file by necessity. A sample file is shown, where some (but not all) of the core pulse laser properties are being updated:
The biggest difference is that this is a dictionary of dictionaries file (similar to the shipdata-overrides.plist file), where the equipment key is the primary dictionary key. techlevel, price, short and long descriptions are now keys, along with all the other settings.
Code: Select all
{
"EQ_WEAPON_PULSE_LASER" = {
techlevel = 7;
price = 50000;
short_description = "Laser Pointer";
long_description = "A simple, all purpose (but weak) laser. Only useful for irritating pirates.";
available_to_all = YES;
weapon_info = {
color = "whiteColor";
};
};
}
- Killer Wolf
- ---- E L I T E ----
- Posts: 2278
- Joined: Tue Jan 02, 2007 12:38 pm
Re: Equipment-overrides :-/
magic, thanks bud
- Killer Wolf
- ---- E L I T E ----
- Posts: 2278
- Joined: Tue Jan 02, 2007 12:38 pm
Re: Equipment-overrides :-/
can you not make new equipment and the overrides particular to a single place? i was tweaking my station to have some better prices but it's all displaying in another Coriolis too.
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Equipment-overrides :-/
If you add aKiller Wolf wrote: ↑Fri Dec 01, 2023 4:43 pmcan you not make new equipment and the overrides particular to a single place? i was tweaking my station to have some better prices but it's all displaying in another Coriolis too.
condition_script
to your equipment item (either in equipment.plist, or in equipment-overrides.plist) you can do two things:1. use the
allowAwardEquipment
to control the visibility of the item at a station:For example, this code will only offer the equipment item for sale if the player is docked at a station with a particular data key:
Code: Select all
this.allowAwardEquipment = function (equipment, ship, context) {
if (context == "scripted") return true; // you should always do this at the top of this function.
if (equipment == "EQ_MY_EQUIPKEY" && ship.isPlayer) {
if (player.ship.dockedStation.dataKey == "my_station") {
return true;
}
}
return false;
}
updateEquipmentPrice
to change the price of an equipment item.For example, this code will take 50% off the normal price of an item when you're docked at a particular station
Code: Select all
this.updateEquipmentPrice - function (equipment, currentPrice) {
var newprice = currentPrice;
if (equipment == "EQ_MY_EQUIPKEY") {
if (player.ship.dockedStation.dataKey == "my_station") {
newprice = parseInt(newprice * 0.5);
}
}
return newprice;
}
equipmentPriceFactor
is applied, so further changes to the price could occur if that value is something other than 1.0.Hope that helps!
- Killer Wolf
- ---- E L I T E ----
- Posts: 2278
- Joined: Tue Jan 02, 2007 12:38 pm
Re: Equipment-overrides :-/
thanks agan bud, i'll have a bit experiment
- Killer Wolf
- ---- E L I T E ----
- Posts: 2278
- Joined: Tue Jan 02, 2007 12:38 pm
Re: Equipment-overrides :-/
seem to have the new equipment working but my prices are still not playing. in my equipment-overrides i've got entries like
and as you had above KWiiprices is
but i'm not getting the recalc
is my if statement wrong?
Code: Select all
"EQ_MISSILE" = {
"condition_script" = "KWiiprices.js";
};
"EQ_CARGO_BAY" = {
"condition_script" = "KWiiprices.js";
};
Code: Select all
this.updateEquipmentPrice - function (equipment, currentPrice) {
var newprice = currentPrice;
if (equipment == "EQ_FUEL" || "EQ_MISSILE" || "EQ_CARGO_BAY") {
if (player.ship.dockedStation.dataKey == "KW_II") {
newprice = parseInt(newprice * 0.5);
}
}
return newprice;
}
is my if statement wrong?
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Equipment-overrides :-/
Kind of.
There's a couple of ways to handle it. If you just want to apply the same discount to *everything*, you'd be better off setting the
equipment_price_factor
of the station in your shipdata.plist file.However, if you only want to discount some selected items, and again use the same discount for all of them, here's some options:
Code: Select all
this.updateEquipmentPrice - function (equipment, currentPrice) {
var newprice = currentPrice;
if (equipment == "EQ_FUEL" || equipment == "EQ_MISSILE" || equipment == "EQ_CARGO_BAY") {
if (player.ship.dockedStation.dataKey == "KW_II") {
newprice = parseInt(newprice * 0.5);
}
}
return newprice;
}
Then there's this:
Code: Select all
this.updateEquipmentPrice - function (equipment, currentPrice) {
var newprice = currentPrice;
if (["EQ_FUEL", "EQ_MISSILE", "EQ_CARGO_BAY"].indexOf(equipment) >= 0) {
if (player.ship.dockedStation.dataKey == "KW_II") {
newprice = parseInt(newprice * 0.5);
}
}
return newprice;
}
Another alternative is:
Code: Select all
this.updateEquipmentPrice - function (equipment, currentPrice) {
var newprice = currentPrice;
switch (equipment) {
case "EQ_FUEL":
case "EQ_MISSILE":
case "EQ_CARGO_BAY":
if (player.ship.dockedStation.dataKey == "KW_II") {
newprice = parseInt(newprice * 0.5);
}
break;
}
return newprice;
}
If equipment is equal to "EQ_FUEL" OR is equal to "EQ_MISSILE" OR is equal to "EQ_CARGO_BAY", then execute the code following. If equipment is not equal to any of those, then skip everything.
The benefit of this last version is it makes it relatively easy to change your mind about discounts on certain items. For instance, if you decide you want to only have a 25% discount on missiles, you rearrange it like this:
Code: Select all
this.updateEquipmentPrice - function (equipment, currentPrice) {
var newprice = currentPrice;
switch (equipment) {
case "EQ_MISSILE":
if (player.ship.dockedStation.dataKey == "KW_II") {
newprice = parseInt(newprice * 0.75);
}
break;
case "EQ_FUEL":
case "EQ_CARGO_BAY":
if (player.ship.dockedStation.dataKey == "KW_II") {
newprice = parseInt(newprice * 0.5);
}
break;
}
return newprice;
}
Code: Select all
this.updateEquipmentPrice - function (equipment, currentPrice) {
if (player.ship.dockedStation.dataKey != "KW_II") return currentPrice;
var newprice = currentPrice;
switch (equipment) {
case "EQ_MISSILE":
newprice = parseInt(newprice * 0.75);
break;
case "EQ_FUEL":
case "EQ_CARGO_BAY":
newprice = parseInt(newprice * 0.5);
break;
}
return newprice;
}
- Killer Wolf
- ---- E L I T E ----
- Posts: 2278
- Joined: Tue Jan 02, 2007 12:38 pm
Re: Equipment-overrides :-/
can't get that to work [your last example], do i still leave the overrides plist as it is, w/ the
"EQ_MISSILE" = {
"condition_script" = "KWiiprices.js";
};
"EQ_CARGO_BAY" = {
"condition_script" = "KWiiprices.js";
};
stuff in it?
"EQ_MISSILE" = {
"condition_script" = "KWiiprices.js";
};
"EQ_CARGO_BAY" = {
"condition_script" = "KWiiprices.js";
};
stuff in it?
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Equipment-overrides :-/
Yes, if you want to do anything with the core equipment items, you'll need to use the overrides.plist
Does your full overrides file look like this:
Code: Select all
{
"EQ_MISSILE" = {
"condition_script" = "KWiiprices.js";
};
"EQ_CARGO_BAY" = {
"condition_script" = "KWiiprices.js";
};
}
- Killer Wolf
- ---- E L I T E ----
- Posts: 2278
- Joined: Tue Jan 02, 2007 12:38 pm
Re: Equipment-overrides :-/
yeah, EQ_FUEL has the long and short description in it too but aside from that it looks ok, everything compiles and is recognised ok, it's just that, eg, a cargo bay is being offered at C400 when i dock, instead of C200.
script is
script is
Code: Select all
this.updateEquipmentPrice - function (equipment, currentPrice) {
var newprice = currentPrice;
switch (equipment) {
case "EQ_MISSILE":
if (player.ship.dockedStation.dataKey == "KW_II") {
newprice = parseInt(newprice * 0.75);
}
break;
case "EQ_FUEL":
case "EQ_CARGO_BAY":
if (player.ship.dockedStation.dataKey == "KW_II") {
newprice = parseInt(newprice * 0.5);
}
break;
}
return newprice;
}
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Equipment-overrides :-/
Code: Select all
this.updateEquipmentPrice - function (equipment, currentPrice) {
- hiran
- Theorethicist
- Posts: 2403
- Joined: Fri Mar 26, 2021 1:39 pm
- Location: a parallel world I created for myself. Some call it a singularity...
Re: Equipment-overrides :-/
Could a linter spot the evaluation of a value without storing it somewhere?phkb wrote: ↑Fri Dec 08, 2023 7:44 pmYour problem is in this line. That should be an = before “function”, not a -.Code: Select all
this.updateEquipmentPrice - function (equipment, currentPrice) {
Sunshine - Moonlight - Good Times - Oolite
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Equipment-overrides :-/
Not sure. I don’t use a Linter normally (I’m a bit old school that way), so I’m not sure what they’re capable of. I probably should look into using one though.
- hiran
- Theorethicist
- Posts: 2403
- Joined: Fri Mar 26, 2021 1:39 pm
- Location: a parallel world I created for myself. Some call it a singularity...
Re: Equipment-overrides :-/
We are talking JavaScript, aren't we? I just googled a bit and found
https://eslint.org/docs/latest/rules/no ... xpressions
It may not spot this situation since the function can have side effects. But then it should spot it since the function call would still not require the minus operation.
We simply need to try this out. Maybe we embed this linter into the Oolite builds to check the resources, and it could also go into the expansion verifier.
Sunshine - Moonlight - Good Times - Oolite