equipmentStatus
Posted: Sun Jan 23, 2011 3:06 am
Hi,
looks like I haven't read the wiki well enough, didn't see it due to my own installation and finally only became aware of it by a bug report.
The wiki says:
Yes, it's possible to work around that. However, I don't understand why this is this way - can the request be answered faster if it doesn't have to report "EQUIPMENT_UNAVAILABLE" when the piece of EQ being tested is not around?
The reason is that the oxp has to check for installed&working EQ from other -optional- oxps. So I would have to code it in a slower way: first check wether that oxp is installed and then check wether it is working. It appears better to me would the code return EQUIPMENT_UNAVAILABLE if that piece of EQ is not available (because the oxp is not installed).
Just curious, no real problem. But it would save the time to double-check...
Screet
looks like I haven't read the wiki well enough, didn't see it due to my own installation and finally only became aware of it by a bug report.
The wiki says:
Code: Select all
function equipmentStatus(equipmentType : equipmentInfoExpression) : String
Tests whether the specified type of equipment is installed, and whether it is functioning. Returns one of the following strings: "EQUIPMENT_OK", "EQUIPMENT_DAMAGED", "EQUIPMENT_UNAVAILABLE". (Prior to Oolite 1.74, this method was only available for the player’s ship.)
Note: by design, this method will throw an exception if called with an equipment type that does not exist. To test whether an equipment type exists, use EquipmentInfo.infoForKey(), which will return null for undefined equipment.
The reason is that the oxp has to check for installed&working EQ from other -optional- oxps. So I would have to code it in a slower way: first check wether that oxp is installed and then check wether it is working. It appears better to me would the code return EQUIPMENT_UNAVAILABLE if that piece of EQ is not available (because the oxp is not installed).
Just curious, no real problem. But it would save the time to double-check...
Screet