Difference between revisions of "Oolite JavaScript Reference: Ship"

From Elite Wiki
(Added exitAI(), reactToAIMessage(), hasSuspendedAI)
(Added target, escorts, temperature, heatInsulation, deployEscorts(), dockEcorts().)
Line 4: Line 4:
 
{{Oolite-future-scripting}}
 
{{Oolite-future-scripting}}
  
The '''<code>Ship</code>''' class is an <code>[[Oolite/Development/Scripting/Class/Entity|Entity]]</code> representing a ship, station, missile, cargo pod or other flying item – anything that can be specified in [[shipdata.plist]]. A <code>Ship</code> has all the properties and methods of a <code>Entity</code>, and several others.
+
The '''<code>Ship</code>''' class is an <code>[[Oolite/Development/Scripting/Class/Entity|Entity]]</code> representing a ship, station, missile, cargo pod or other flying item – anything that can be specified in [[shipdata.plist]]. A <code>Ship</code> has all the properties and methods of a <code>Entity</code>, and several others.
  
 
<code>[[Oolite/Development/Scripting/Class/Station|Station]]</code>s and the <code>[[Oolite/Development/Scripting/Class/Player|Player]]</code> are types of ship. Note that these more specific types have additional properties and methods.
 
<code>[[Oolite/Development/Scripting/Class/Station|Station]]</code>s and the <code>[[Oolite/Development/Scripting/Class/Player|Player]]</code> are types of ship. Note that these more specific types have additional properties and methods.
Line 22: Line 22:
  
 
=== <code>AIState</code> ===
 
=== <code>AIState</code> ===
  AIState [read-write string, read-only for player]
+
  AIState [read/write string, read-only for player]
 
The ship’s AI’s current state. (See also: <code>[[#AI|AI]]</code>, <code>[[#reactToAIMessage|reactToAIMessage()]]</code>, <code>[[#hasSuspendedAI|hasSuspendedAI]]</code>)
 
The ship’s AI’s current state. (See also: <code>[[#AI|AI]]</code>, <code>[[#reactToAIMessage|reactToAIMessage()]]</code>, <code>[[#hasSuspendedAI|hasSuspendedAI]]</code>)
  
 
=== <code>fuel</code> ===
 
=== <code>fuel</code> ===
  fuel [read-write double]
+
  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: <code>[[Oolite/Development/Scripting/Class/Player#fuelLeakRate|Player.fuelLeakRate]]</code>)
 
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: <code>[[Oolite/Development/Scripting/Class/Player#fuelLeakRate|Player.fuelLeakRate]]</code>)
  
 
=== <code>bounty</code> ===
 
=== <code>bounty</code> ===
  bounty [read-write integer]
+
  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.
 
The bounty on the ship. This also determines its legal status. In the case of the player, it is halved at each witchspace jump.
  
Line 40: Line 40:
 
  hasSuspendedAI [read-only boolean]
 
  hasSuspendedAI [read-only boolean]
 
<code>true</code> if the ship has suspended AIs, <code>false</code> otherwise.
 
<code>true</code> if the ship has suspended AIs, <code>false</code> otherwise.
 +
 +
=== <code>target</code> ===
 +
target [read/write [[Oolite/Development/Scripting/Class/Ship|Ship]]]
 +
The ship’s primary target, i.e. the entity it will attempt to shoot at.
 +
 +
=== <code>escorts</code> ===
 +
target [read-only array of [[Oolite/Development/Scripting/Class/Entity|Entity]]s]
 +
The ship’s deployed targets.
 +
 +
=== <code>temperature</code> ===
 +
temperature [read/write double]
 +
The ship’s temperature, normalized such that a temperature of 1.0 is the level at which a ship starts taking heat damage.
 +
 +
=== <code>heatInsulation</code> ===
 +
heatInsulation [read/write double]
 +
The ship’s heat insulation factor. 1.0 is normal, higher values mean more resistance to heat.
  
 
== Methods ==
 
== Methods ==
Line 57: Line 73:
 
  void reactToAIMessage(AIState)
 
  void reactToAIMessage(AIState)
 
Immediately execute the ship’s AI in the specified state.
 
Immediately execute the ship’s AI in the specified state.
 +
 +
=== <code>deployEscorts</code> ===
 +
void deployEscorts()
 +
Launch the ship’s escorts, if any.
 +
 +
=== <code>dockEscorts</code> ===
 +
void dockEscorts()
 +
Dock the ship’s deployed escorts, if any.

Revision as of 23:31, 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(), exitAI())

AIState

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

The ship’s AI’s current state. (See also: AI, reactToAIMessage(), hasSuspendedAI)

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.

hasSuspendedAI

hasSuspendedAI [read-only boolean]

true if the ship has suspended AIs, false otherwise.

target

target [read/write Ship]

The ship’s primary target, i.e. the entity it will attempt to shoot at.

escorts

target [read-only array of Entitys]

The ship’s deployed targets.

temperature

temperature [read/write double]

The ship’s temperature, normalized such that a temperature of 1.0 is the level at which a ship starts taking heat damage.

heatInsulation

heatInsulation [read/write double]

The ship’s heat insulation factor. 1.0 is normal, higher values mean more resistance to heat.

Methods

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. (See also: AI, switchAI(), exitAI())

switchAI

void switchAI(AIName)

Set the current AI, exiting the old one. Equivalent to the switchAITo: AI method. May not be used on player. (See also: AI, setAI(), exitAI())

exitAI

void exitAI()

Exit the current AI, restoring the previous one. Equivalent to the exitAI: AI method. May not be used on player. Will generate a warning if there are no suspended AI states. (See also: AI, setAI(), hasSuspendedAI)

reactToAIMessage

void reactToAIMessage(AIState)

Immediately execute the ship’s AI in the specified state.

deployEscorts

void deployEscorts()

Launch the ship’s escorts, if any.

dockEscorts

void dockEscorts()

Dock the ship’s deployed escorts, if any.