There are two problems with this.dertien wrote:actuators.add();
A) There isn't a "
.add()
" method to counter ".remove()
". To put a subentity back onto a ship, you have to:1 - remember which subentities you currently have
2 - call
ship.restoreSubEntities()
to reset the ship back to its factory default3 - remove any subentities, except the one you meant to add, which aren't on the list you made in step 1
Unfortunately with the way Oolite specifies subentities at the moment, writing a built-in method to only restore a specific subentity is difficult (for those about to ask: because there's no unambiguous way to specify which subentity to restore given that you want the restore to fail if it's already on the ship)
B) Because the subentity isn't already on the ship when you want to add it,
_findSubEntity
will return null, so "if (actuators)
" will be false, so it'll never run the actuators.add()
line anyway - and if it did, it would run null.add()
, which wouldn't help you.An easier way to handle this, assuming the subentities are relatively small compared with the main hull, is rather than removing them, reposition them.
Code: Select all
var actuators = this._findSubEntity("HPC_actuatorR"); //make actuator visible during station launch sequence
if (actuators)
{
actuators.position = [0,-30,0];
}
var reargearextendPRT = this._findSubEntity("HPC_reargearPRT");
if (reargearextendPRT)
{
reargearextendPRT.position = [0,0,0];
}
var reargearextendSTB = this._findSubEntity("HPC_reargearSTB");
if (reargearextendSTB)
{
reargearextendSTB.position = [0,0,0];
}
shipdata.plist
- so rather than adding or removing the subentities, you hide them inside the centre of the ship when they're not in use, and return them to their normal positions when they are needed again.As far as the lasers go, that should work (assuming you were watching an NPC try to shoot, that is)