Hi all,
Yet again my lack of understanding of js has reared it's head!
I want to place one escort in a specific position next to its Mother. After looking through the Wiki and BB I came up with this which is called from the mother's shipdata.plist
Thanks KW.
I'm not sure that is what I need though. My requirement is actually much simpler. I just want to spawn one escort in a precise position near the mother. It's a special case as neither will move at any time (the mother is actually a small station a bit like a rock hermit) so there is no formation to maintain, and I don't need or want the escort to move into position....I just need it to be there as the mother is spawned, in exactly the right position.
Commander Smivs, the friendliest Gourd this side of Riedquat.
I think the best solution for this case is to move the escort immediately after spawning. That's how for instance the Sentinel Asteroids are positioned around a Hacker Outpost. It's done in the Hacker Outpost's ship script, and the steps are relatively straightforward:
Once your station exists, let it search for its escort. As soon as it has found the escort, change its position to whatever you want.
So what you basically need is the following in the station's script:
I'm sure there is an easier way to write this, but it works. So if you want to place the escort 500 meters behind and 300 meters to the right of the station, simply insert the numbers -500 and 300 in the first two brackets and delete the last .add-part.
Hi all,
Yet again my lack of understanding of js has reared it's head!
I want to place one escort in a specific position next to its Mother. After looking through the Wiki and BB I came up with this which is called from the mother's shipdata.plist
(function () {
this.coordinatesForEscortPosition = function (index)
{
var position = Vector3D("your position here based on index")
return position;
}
}).call(this);
On ship creation Oolite already adds the escorts on the intended escort position. When you really have one escort, you probably could ignore the index and always return (15, -80, 230). Better would be to make sure every value of "index" returns a different position.
Or perhaps simpler to access the escort via this.ship.escorts to ensure that it's only the escort of the station that gets accessed. this.ship.escorts is an array of all the escorts that an entity has, so you can check the escort exists (this.ship.escorts.length > 0 or in this case === 1) and then access it as this.ship.escorts[0] again after checking that exists in the script sequence.
You can then set this.ship.escorts[0].position = [x,y,z] in the normal fashion as in McLane's suggestion above.