Discussion and information relevant to creating special missions, new ships, skins etc.
Moderators: winston , another_commander
Commander McLane
---- E L I T E ----
Posts: 9520 Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:
Post
by Commander McLane » 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:
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]);
...
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?
JensAyton
Grand Admiral Emeritus
Posts: 6657 Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:
Post
by JensAyton » Sun Feb 20, 2011 8:47 pm
this.fireworker[0].group = station.group
. Being a member of the group doesn’t make it the ship’s “main” group, because a ship can belong to any number of groups (and you can create groups to track any set of ships you please).
Commander McLane
---- E L I T E ----
Posts: 9520 Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:
Post
by Commander McLane » Sun Feb 20, 2011 8:57 pm
Ah, yes! And I
did know that once.
Thanks, Ahruman!