Difference between revisions of "Oolite JavaScript Reference: Player"
m (→Methods: Corrected order.) |
(Changed future-scripting tag to added-in-1.70, updated links.) |
||
Line 1: | Line 1: | ||
− | <small>'''Prototype:''' <code>[[Oolite | + | <small>'''Prototype:''' <code>[[Oolite JavaScript Reference: Ship|Ship]]</code></small><br /> |
− | {{Oolite- | + | {{Oolite-class-added|1.70}} |
− | The '''<code>Player</code>''' class is an <code>[[Oolite | + | The '''<code>Player</code>''' class is an <code>[[Oolite JavaScript Reference: Entity|Entity]]</code> representing the player, and the player’s ship – the two are inseperable. The <code>Player</code> has all the properties and methods of a <code> [[Oolite JavaScript Reference: Ship|Ship]]</code>, and several others. There is always exactly one <code>Player</code> object in existence, which can be accessed through the <code>player</code> global property. |
== Properties == | == Properties == | ||
Line 44: | Line 44: | ||
=== <code>alertEnergy</code> === | === <code>alertEnergy</code> === | ||
alertEnergy [read-only boolean] | alertEnergy [read-only boolean] | ||
− | Whether the player’s energy level is depleted (i.e., <code>[[Oolite | + | Whether the player’s energy level is depleted (i.e., <code>[[Oolite JavaScript Reference: Entity#energy|energy]]</code> is less than <code>[[Oolite JavaScript Reference: Entity#maxEnergy|maxEnergy]]</code>). |
=== <code>alertHostiles</code> === | === <code>alertHostiles</code> === | ||
Line 51: | Line 51: | ||
=== <code>dockedStation</code> === | === <code>dockedStation</code> === | ||
− | dockedStation [read-only [[Oolite | + | dockedStation [read-only [[Oolite JavaScript Reference: Station|Station]]] |
The station with which the player is currently docked. | The station with which the player is currently docked. | ||
== Deprecated properties == | == Deprecated properties == | ||
The following properties are deprecated as of Oolite 1.70, and will be removed before the next stable release: | The following properties are deprecated as of Oolite 1.70, and will be removed before the next stable release: | ||
− | * '''<code>legalStatus</code>''': use <code>[[Oolite | + | * '''<code>legalStatus</code>''': use <code>[[Oolite JavaScript Reference: Ship#bounty|bounty]]</code> instead. |
− | * '''<code>dockedStationName</code>''': use <code>[[#dockedStation|dockedStation]].[[Oolite | + | * '''<code>dockedStationName</code>''': use <code>[[#dockedStation|dockedStation]].[[Oolite JavaScript Reference: Ship#shipDescription|shipDescription]]</code> instead. |
− | * '''<code>dockedAtMainStation</code>''': use <code>[[#dockedStation|dockedStation]].[[Oolite | + | * '''<code>dockedAtMainStation</code>''': use <code>[[#dockedStation|dockedStation]].[[Oolite JavaScript Reference: Ship#isMainStation|isMainStation]]</code> instead. |
Revision as of 11:00, 6 December 2007
Prototype: Ship
This class was added in Oolite test release 1.70.
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.
Contents
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.
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:
legalStatus
: usebounty
instead.dockedStationName
: usedockedStation.shipDescription
instead.dockedAtMainStation
: usedockedStation.isMainStation
instead.
Methods
awardEquipment
void awardEquipment(equipmentKey)
Adds the given piece of equipment to the player’s ship. Example: player.awardEquipment("EQ_TRUMBLE")
commsMessage
commsMessage(message : String [, duration: Number])
Writes the specified message in the player’s communications log, as well as displaying it as a console message. The optional duration
parameter determines how long the message should be displayed on the console before fading out. It is clamped to the range [1, 10]. If no duration is specified, 4.5 seconds will be used.
consoleMessage
consoleMessage(message : String [, duration: Number])
Displays the specified message as a console message, that is, as a message on the HUD. The optional duration
parameter determines how long the message should be displayed before fading out. It is clamped to the range [1, 10]. If no duration is specified, 3 seconds will be used.
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.