Difference between revisions of "Oolite JavaScript Reference: Entity"

From Elite Wiki
m
(Moving Oolite JS reference into a subcategory of Oolite scripting.)
Line 84: Line 84:
 
<code>true</code> if the entity is a valid entity variable, <code>false</code> if it is [[#Stale References|stale]].
 
<code>true</code> if the entity is a valid entity variable, <code>false</code> if it is [[#Stale References|stale]].
  
[[Category:Oolite scripting]]
+
[[Category:Oolite JavaScript Reference]]

Revision as of 14:09, 19 June 2010

Prototype: Object
Subtypes: Planet, Ship, Sun

The Entity class represents an object in the game universe. Ships, Stations, Planets and the Playerare 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

distanceTravelled

distanceTravelled : Number (read-only)

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

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().

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)

See Also: setOrientation()

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)

See Also: setPosition()

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”).

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, 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.