Oolite JavaScript Reference: Player

From Elite Wiki
Revision as of 21:35, 2 August 2007 by Ahruman (talk | contribs) (New page: <small>'''Prototype:''' <code>Ship</code></small><br /> {{Oolite-future-scripting}} The '''<code>Player</code>''' class is an <code>[[Oolite/D...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Prototype: Ship

The Player class is an Entity representing the player, and the player’s ship – the two are inseperable. The Player has all the properties and methods of a Ship, and several others. There is always exactly one Player object in existence, which can be accessed through the player global property.

Properties

name

name [read-only string]

The name of the player’s character (e.g., “Jameson”).

score

score [read-write integer]

The player’s score; nominally the number of kills the player has made, although some missions award additional points.

score

score [read-write integer]

An integer value related to the number of kills the player has (1 ship does not always = 1 kill).

credits

credits [read-write integer]

The amount of money the player has.

fuelLeakRate

fuelLeakRate [read-write double]

The rate at which the player is losing fuel, in tenths of a LY per second. May not be negative. Reset to 0 when fuel is empty.

alertCondition

alertCondition [read-only integer]

Returns the current alert condition. 0 = Docked, 1 = Green, 2 = Yellow, 3 = Red.

docked

docked [read-only boolean]

True if the player is docked with a station or carrier.

alertTemperature

alertTemperature [read-only boolean]

Whether the cabin temperature is dangerously high.

alertMassLocked

alertMassLocked [read-only boolean]

Whether the player is mass locked.

alertAltitude

alertAltitude [read-only boolean]

Whether the player is dangerously close to a planet.

alertEnergy

alertEnergy [read-only boolean]

Whether the player’s energy level is depleted (i.e., energy is less than maxEnergy).

alertHostiles

alertHostiles [read-only boolean]

Whether there are hostile ships within scanner range.

dockedStation

dockedStation [read-only Station]

The station with which the player is currently docked.

Deprecated properties

The following properties are deprecated as of Oolite 1.70, and will be removed before the next stable release:


Methods

awardEquipment

void awardEquipment(equipmentKey)

Adds the given piece of equipment to the player’s ship. Example: player.awardEquipment("EQ_TRUMBLE")

removeEquipment

void removeEquipment(equipmentKey)

Removes the given piece of equipment from the player’s ship. Example: player.removeEquipment("EQ_TRUMBLE")

hasEquipment

boolean hasEquipment(equipmentKey)

Returns true if the given piece of equipment is present on/in the player’s ship, false if it is not. Example: if (player.hasEquipment("EQ_TRUMBLE")) Log("Oh noes, I has a trumble!")

awardCargo

void awardCargo(cargoname, amount)

Awards the given amount of the specified type of cargo. The cargo name must match the name in commodities.plist exactly.

removeAllCargo

void removeAllCargo()

Removes all cargo from the ship’s cargo bay.

useSpecialCargo

void useSpecialCargo(description)

Fills the cargo bay with the cargo described, effectively disabling the use of the cargo bay until the cargo is removed.

launch

void launch()

Launches the player’s ship if it is currently docked.