adding a ship to a group
Posted: Sun Feb 20, 2011 8:10 pm
Stupid question (and I think I knew it once, but I can't figure it out now):
How do I add a newly created ship to an existing ship group? Specifically how does the newly added ship get to know that it's part of a group now?
I want to make the fireworkers part of the station group. They're spawned like this:
I thought the last line would do the trick. However, it does only half the trick. The station is aware of the fireworkers. But the fireworkers themselves claim to belong to no group whatsoever. How can this be? And how can I make them aware of their new community?
How do I add a newly created ship to an existing ship group? Specifically how does the newly added ship get to know that it's part of a group now?
I want to make the fireworkers part of the station group. They're spawned like this:
Code: Select all
this.shipWillLaunchFromStation = function(station)
{
if(player.ship.equipmentStatus("EQ_FIREWORKS") === "EQUIPMENT_OK")
{
var orientation = station.orientation
this.fireworker = system.addShips("fireworks_fireworker", 1, station.position.add(orientation.vectorForward().multiply(3600)).add(orientation.vectorRight().multiply(500)), 0);
this.fireworker[0].orientation = orientation;
station.group.addShip(this.fireworker[0]);
...