Difference between revisions of "Oolite JavaScript Reference: Ship"

From Elite Wiki
m (<code>subEntities</code>: Formatting twiddle.)
m (Properties: Formatting consistency)
Line 39: Line 39:
 
== Properties ==
 
== Properties ==
 
=== <code>setAI</code> ===
 
=== <code>setAI</code> ===
void setAI(AIName);
+
void setAI(AIName)
 
Set the current AI, leaving the old one suspended. Equivalent to the <code>[[AI_methods|setAITo]]:</code> AI method. May not be used on player.
 
Set the current AI, leaving the old one suspended. Equivalent to the <code>[[AI_methods|setAITo]]:</code> AI method. May not be used on player.
   
 
=== <code>switchAI</code> ===
 
=== <code>switchAI</code> ===
void switchAI(AIName);
+
void switchAI(AIName)
 
Set the current AI, exiting the old one. Equivalent to the <code>[[AI_methods|switchAITo]]:</code> AI method. May not be used on player.
 
Set the current AI, exiting the old one. Equivalent to the <code>[[AI_methods|switchAITo]]:</code> AI method. May not be used on player.

Revision as of 17:28, 3 August 2007

Prototype: Entity
Subtypes: Station, Player

The Ship class is an Entity representing a ship, station, missile, cargo pod or other flying item – anything that can be specified in shipdata.plist. A Ship has all the properties and methods of a Entity, and several others.

Stations and the Player are types of ship. Note that these more specific types have additional properties and methods.

Properties

shipDescription

shipDescription [read-only string]

The name of the ship type (name key in shipdata.plist).

roles

roles [read-only array]

The roles of the ship. Probabilities are not included.

AI

AI [read-only string]

The name of the ship’s current AI. (See also: AIState, setAI(), switchAI())

AIState

AIState [read-write string, read-only for player]

The ship’s AI’s current state. (See also: AI, setAI(), switchAI())

fuel

fuel [read-write double]

The ship’s current fuel capacity, in LY. The game will limit this to the range 0..7, and round it off to the nearest tenth. (See also: Player.fuelLeakRate)

bounty

bounty [read-write integer]

The bounty on the ship. This also determines its legal status. In the case of the player, it is halved at each witchspace jump.

subEntities

subEntities [read-only array of Ships]

The ships subentities, or null if it has none. Special subentities such as flashers and exhaust plumes are not included.

Properties

setAI

void setAI(AIName)

Set the current AI, leaving the old one suspended. Equivalent to the setAITo: AI method. May not be used on player.

switchAI

void switchAI(AIName)

Set the current AI, exiting the old one. Equivalent to the switchAITo: AI method. May not be used on player.