Difference between revisions of "Oolite JavaScript Reference: Entity"

From Elite Wiki
(Added isVisible)
m (Alphabetical sorting)
Line 25: Line 25:
   
 
<code>entity.heading()</code> is equivalent to <code>entity.[[#orientation|orientation]].[[Oolite JavaScript Reference: Quaternion#forwardVector|forwardVector]]()</code>.
 
<code>entity.heading()</code> is equivalent to <code>entity.[[#orientation|orientation]].[[Oolite JavaScript Reference: Quaternion#forwardVector|forwardVector]]()</code>.
  +
  +
=== <code>isPlanet</code> ===
  +
'''isPlanet''' : Boolean (read-only)
  +
<code>true</code> if the entity is a [[Oolite JavaScript Reference: Planet|Planet]], <code>false</code> otherwise.
  +
  +
=== <code>isPlayer</code> ===
  +
'''isPlayer''' : Boolean (read-only)
  +
<code>true</code> if the entity is the [[Oolite JavaScript Reference: PlayerShip|player ship]], <code>false</code> otherwise.
  +
  +
=== <code>isShip</code> ===
  +
'''isShip''' : Boolean (read-only)
  +
<code>true</code> if the entity is a [[Oolite JavaScript Reference: Ship|Ship]], <code>false</code> otherwise.
  +
  +
=== <code>isStation</code> ===
  +
'''isStation''' : Boolean (read-only)
  +
<code>true</code> if the entity is a [[Oolite JavaScript Reference: Station|Station]], <code>false</code> otherwise.
  +
  +
=== <code>isSubEntity</code> ===
  +
'''isSubEntity''' : Boolean (read-only)
  +
<code>true</code> if the entity is a subentity, <code>false</code> otherwise. A subentity’s owner can be acquired through the <code>[[#owner|owner]]</code> property.
  +
  +
=== <code>isSun</code> ===
  +
'''isSun''' : Boolean (read-only)
  +
<code>true</code> if the entity is a [[Oolite JavaScript Reference: Sun|Sun]], <code>false</code> otherwise.
  +
  +
=== <code>isValid</code> ===
  +
'''isValid''' : Boolean (read-only)
  +
<code>true</code> if the entity is a valid entity variable, <code>false</code> if it is [[#Stale References|stale]].
   
 
=== <code>isVisible</code> ===
 
=== <code>isVisible</code> ===
Line 60: Line 88:
 
'''status''' : String (read-only)
 
'''status''' : String (read-only)
 
The current status of the entity (such as “STATUS_IN_FLIGHT” and “STATUS_BEING_SCOOPED”).
 
The current status of the entity (such as “STATUS_IN_FLIGHT” and “STATUS_BEING_SCOOPED”).
 
=== <code>isPlanet</code> ===
 
'''isPlanet''' : Boolean (read-only)
 
<code>true</code> if the entity is a [[Oolite JavaScript Reference: Planet|Planet]], <code>false</code> otherwise.
 
 
=== <code>isPlayer</code> ===
 
'''isPlayer''' : Boolean (read-only)
 
<code>true</code> if the entity is the [[Oolite JavaScript Reference: PlayerShip|player ship]], <code>false</code> otherwise.
 
 
=== <code>isShip</code> ===
 
'''isShip''' : Boolean (read-only)
 
<code>true</code> if the entity is a [[Oolite JavaScript Reference: Ship|Ship]], <code>false</code> otherwise.
 
 
=== <code>isStation</code> ===
 
'''isStation''' : Boolean (read-only)
 
<code>true</code> if the entity is a [[Oolite JavaScript Reference: Station|Station]], <code>false</code> otherwise.
 
 
=== <code>isSubEntity</code> ===
 
'''isSubEntity''' : Boolean (read-only)
 
<code>true</code> if the entity is a subentity, <code>false</code> otherwise. A subentity’s owner can be acquired through the <code>[[#owner|owner]]</code> property.
 
 
=== <code>isSun</code> ===
 
'''isSun''' : Boolean (read-only)
 
<code>true</code> if the entity is a [[Oolite JavaScript Reference: Sun|Sun]], <code>false</code> otherwise.
 
 
=== <code>isValid</code> ===
 
'''isValid''' : Boolean (read-only)
 
<code>true</code> if the entity is a valid entity variable, <code>false</code> if it is [[#Stale References|stale]].
 
   
 
[[Category:Oolite JavaScript Reference]]
 
[[Category:Oolite JavaScript Reference]]

Revision as of 08:55, 22 May 2012

Prototype: Object
Subtypes: Planet, Ship, Sun

The Entity class represents an object in the game universe. Ships, Stations, Planets and Suns are types of entity. Note that these more specific types have additional properties and methods.

Stale References

When an entity dies or is otherwise removed from the game universe (for instance, because player jumped from the system), existing Entity variables referring to the entity become invalid; all their properties become undefined, and their methods do nothing. In addition to the undefined properties, this can be detected with the isValid property.

Properties

collisionRadius

collisionRadius : Number (read-only)

The radius of the entity, in game meters. This is the radius of the spherical entity representation Oolite calculates with for non-colliding entities.

distanceTravelled

distanceTravelled : Number (read-only)

The distance the entity has travelled since being spawned, in game meters.

energy

energy : Number (read/write)

The entity’s total energy; ranges from 0 to maxEnergy.

heading

heading : Vector (read-only)

The heading of the entity. This is equivalent to orientation, but ignoring the axial twist component (roll in the case of a ship).

entity.heading() is equivalent to entity.orientation.forwardVector().

isPlanet

isPlanet : Boolean (read-only)

true if the entity is a Planet, false otherwise.

isPlayer

isPlayer : Boolean (read-only)

true if the entity is the player ship, false otherwise.

isShip

isShip : Boolean (read-only)

true if the entity is a Ship, false otherwise.

isStation

isStation : Boolean (read-only)

true if the entity is a Station, false otherwise.

isSubEntity

isSubEntity : Boolean (read-only)

true if the entity is a subentity, false otherwise. A subentity’s owner can be acquired through the owner property.

isSun

isSun : Boolean (read-only)

true if the entity is a Sun, false otherwise.

isValid

isValid : Boolean (read-only)

true if the entity is a valid entity variable, false if it is stale.

isVisible

This property was added in Oolite test release 1.77.

isVisible : Boolean (read-only)

Determines if the entity is close enough to the player to be drawn.

mass

mass : Number (read-only)

The mass of the entity. Currently, this is directly proportional to the volume.

maxEnergy

maxEnergy : Number (read-only)

The highest permissible value of energy.

orientation

orientation : Quaternion (read/write)

owner

owner : Entity (read-only)

The entity which owns this one. In the case of a subentity, the entity to which it is attached. In the case of a defense ship, the station it belongs to. In the case of a missile, the ship that launched it. There may be other uses.

position

position : Vector (read/write)

scanClass

scanClass : String (read-only)

The current scan class of the entity (such as “CLASS_NEUTRAL” and “CLASS_CARGO”).

spawnTime

spawnTime : Number (read-only)

The time at which the entity came into existence.

status

status : String (read-only)

The current status of the entity (such as “STATUS_IN_FLIGHT” and “STATUS_BEING_SCOOPED”).