If EQ_A lists EQ_B as incompatible, but not vice-versa:
-if the player installs EQ_A and then EQ_B he will have both, until the next save/load
-if the player installs EQ_B, he won't be offered EQ_A
If the savefile has both EQ_A and EQ_B in extra equipment dictionary, the player will lose EQ_A when he loads the savefile.
If a script awards EQ_A and then EQ_B, the ships has both.
if a script awards EQ_B and then EQ_A, the second award fails.
Right now it's possible to have both EQ_A and EQ_B for a game session if acquired in the right order... but the clean-up at game load time tells me that's not how it should be... if that's so, then equipmentAdded event handler in oolite-equipment-control.js needs some work!
Equipment incompatibility handling
Moderators: winston, another_commander, Getafix
Re: Equipment incompatibility handling
Code: Select all
/* Add equipment effects */
this.equipmentAdded = function(equip)
{
if (!this.$started)
{
return;
}
if (!this.$equipmentEnabled[equip])
{
if (this.$equipmentEnable[equip])
{
var info = EquipmentInfo.infoForKey(equip);
// log(this.name,"Enabling "+info.equipmentKey); //tmp - remove later
var result = this.$equipmentEnable[equip].bind(this,info)();
if (result == -1)
{
| return;
}
}
}
var eq_dict = this.$equipmentEnabled;
var eqIncompatible;
for (eqKey in eq_dict) {
eqIncompatible = EquipmentInfo.infoForKey(eqKey).incompatibleEquipment;
if (eqIncompatible && eqIncompatible.indexOf(equip) >= 0) {
player.ship.removeEquipment(eqKey);
}
}
this.$equipmentEnabled[equip] = 1;
};
EDIT: I posted this in the wrong topic... now moved to the correct one
Re: Equipment incompatibility handling
I would like to create a branch in the github repo and then a PR... whom should I contact to get permission to create a branch/PR?
- 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 incompatibility handling
I've added the branch and PR for the time being.
Re: Equipment incompatibility handling
Found a problem with my code, EquipmentInfo.inforForKey doesn't return an object for those EQ_NUMERIC* from the HUD...
Revised code:
Code: Select all
23:22:54.175 [LogEvents]: ship lost EQ_NUMERIC3_ALERTCONDITIONGREEN
23:22:54.175 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (Oolite Equipment Control 1.89): TypeError: EquipmentInfo.infoForKey(eqKey) is null
23:22:54.175 [script.javaScript.exception.unexpectedType]: /home/dybal/GNUstep/Applications/Oolite-trunk/oolite.app/Resources/Scripts/oolite-equipment-control.js, line 162.
Code: Select all
var eq_dict = this.$equipmentEnabled;
var eqInfo;
for (eqKey in eq_dict) {
eqInfo = EquipmentInfo.infoForKey(eqKey);
if (eqInfo && eqInfo.incompatibleEquipment && eqInfo.incompatibleEquipment.indexOf(equip) >= 0) {
player.ship.removeEquipment(eqKey);
}
}
this.$equipmentEnabled[equip] = 1;
- 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 incompatibility handling
Was also missing a declaration for eqKey. New PR added.
Re: Equipment incompatibility handling
So it does...
The interpreter didn't take objection to the lack: there were no errors in Latest.log when I run it (and I had a trace inside the loop to check things since I wasn't seeing the behaviour I expected when loading a savefile with a pair of incompatible equipments - the problem wasn't here but at the equipments' declaration in equipment.plist though - so I'm sure that code was executed)
Anyway, thanks for applying and correcting it!