Difference between revisions of "Oolite JavaScript Reference: Player"
m (→Properties: Duplicate entry.) |
m (Moving draft scripting documentation to separate category.) |
||
Line 53: | Line 53: | ||
dockedStation [read-only [[Oolite/Development/Scripting/Class/Station|Station]]] | dockedStation [read-only [[Oolite/Development/Scripting/Class/Station|Station]]] | ||
The station with which the player is currently docked. | The station with which the player is currently docked. | ||
− | |||
− | |||
== Deprecated properties == | == Deprecated properties == |
Revision as of 14:35, 3 August 2007
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.
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")
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.