adding a ship to a group

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
Commander McLane
---- E L I T E ----
---- 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:

adding a ship to a group

Post by Commander McLane »

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?
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: adding a ship to a group

Post by JensAyton »

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).
User avatar
Commander McLane
---- E L I T E ----
---- 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:

Re: adding a ship to a group

Post by Commander McLane »

Ah, yes! And I did know that once. :oops:

Thanks, Ahruman! :D
Post Reply