Difference between revisions of "Oolite JavaScript Reference: ShipGroup"

From Elite Wiki
(Moving Oolite JS reference into a subcategory of Oolite scripting.)
m (Moving Oolite JS reference into a *correctly-named* subcategory of Oolite scripting.)
Line 44: Line 44:
 
Boolean, returns true when the ship belongs to the group. When not it returns false.
 
Boolean, returns true when the ship belongs to the group. When not it returns false.
  
[[Category:Oolite JavaScript reference]]
+
[[Category:Oolite JavaScript Reference]]

Revision as of 14:06, 19 June 2010

This class was added in Oolite test release 1.73.

The ShipGroup class is a property of an Entity representing a group of ships.

Constructor

new ShipGroup() : ShipGroup

Creates a new group to which ships can be added. e.g.

var myGroup = new ShipGroup();
myGroup.name = "My group";
myShip.group = myGroup;

Properties

ships

ships : Array of entites (read-only)

leader

leader : Entity (read/write)

Defines a leader for the group. When the ship is not on the group list, he is added to the group.

name

name : String (read/write)

Name of the shipgroup.

count

count : Integer (read-only)

Number of ships in the group, including leader.


Methods

toString

function toString()

Returns the whole group as a human readable string.

addShip

function addShip([ship : Entity])

Adds an entity to a group.

removeShip

function removeShip([ship : Entity])

Removes an entity to a group.

containsShip

function containsShip([ship : Entity])

Boolean, returns true when the ship belongs to the group. When not it returns false.