Difference between revisions of "Oolite JavaScript Reference: Player"
(Update for 1.75.) |
(→Properties: Moving cargoSpaceAvailable and cargoSpaceUsed from Ship to PlayerShip. (Bug #18243)) |
||
Line 34: | Line 34: | ||
'''See also''': <code>[[#legalStatus|legalStatus]]</code> |
'''See also''': <code>[[#legalStatus|legalStatus]]</code> |
||
+ | |||
+ | === <code>cargoSpaceAvailable</code> === |
||
+ | '''cargoSpaceAvailable''' : Number (read-only integer) |
||
+ | The ship’s available cargo space, in tons. |
||
+ | |||
+ | === <code>cargoSpaceUsed</code> === |
||
+ | '''cargoSpaceUsed''' : Number (read-only integer) |
||
+ | The ship’s current cargo, in tons. |
||
=== <code>contractReputation</code> === |
=== <code>contractReputation</code> === |
||
Line 79: | Line 87: | ||
'''trumbleCount''' : Number (read-only nonnegative integer) |
'''trumbleCount''' : Number (read-only nonnegative integer) |
||
The number of trumbles the player is currently blessed with. |
The number of trumbles the player is currently blessed with. |
||
− | |||
== Methods == |
== Methods == |
Revision as of 13:28, 16 July 2011
Prototype: Object
Subtypes: none
The Player
class is represents the player. There is always exactly one Player
object in existence, which can be accessed through the player
global property.
Contents
- 1 Properties
- 1.1 alertAltitude
- 1.2 alertCondition
- 1.3 alertEnergy
- 1.4 alertHostiles
- 1.5 alertMassLocked
- 1.6 alertTemperature
- 1.7 bounty
- 1.8 cargoSpaceAvailable
- 1.9 cargoSpaceUsed
- 1.10 contractReputation
- 1.11 credits
- 1.12 dockingClearanceStatus
- 1.13 legalStatus
- 1.14 name
- 1.15 passengerReputation
- 1.16 rank
- 1.17 score
- 1.18 trumbleCount
- 2 Methods
Properties
alertAltitude
alertAltitude : Boolean (read-only)
Whether the player is dangerously close to a planet. (closer than 4000 meter to the surface)
alertCondition
alertCondition : Number (read-only, integer)
Returns the current alert condition. 0 = Docked, 1 = Green, 2 = Yellow, 3 = Red.
alertEnergy
alertEnergy : Boolean (read-only)
Whether the player’s energy level is depleted (i.e., energy
is less than maxEnergy
).
alertHostiles
alertHostiles : Boolean (read-only)
Whether there are hostile ships within scanner range.
alertMassLocked
alertMassLocked : Boolean (read-only)
Whether the player is mass locked.
alertTemperature
alertTemperature : Boolean (read-only)
Whether the cabin temperature is dangerously high.
bounty
bounty : Number (read/write integer)
The bounty on the player, which determines legal status. It is halved at each witchspace jump.
See also: legalStatus
cargoSpaceAvailable
cargoSpaceAvailable : Number (read-only integer)
The ship’s available cargo space, in tons.
cargoSpaceUsed
cargoSpaceUsed : Number (read-only integer)
The ship’s current cargo, in tons.
contractReputation
contractReputation : Number (read-only integer)
The player’s cargo contract reputation, ranging from -7 to +7. Reputation is based on fulfilled and unfulfilled contracts. Both individually ranging from 0 till 7. Both good and bad value erode away in time towards 0. All individually values below 7 are seen as unknown reputation. This unknown part is randomised based on the market situation.
See also: decreaseContractReputation()
, increaseContractReputation()
, passengerReputation
credits
credits : Number (read/write, integer)
The amount of money the player has.
dockingClearanceStatus
dockingClearanceStatus : String (read-only)
A string indicating whether the player has docking clearance. (Clarify: for which station? -Ahruman 20:34, 3 November 2008 (UTC)) Possible values are:
"DOCKING_CLEARANCE_STATUS_NONE"
"DOCKING_CLEARANCE_STATUS_REQUESTED"
"DOCKING_CLEARANCE_STATUS_NOT_REQUIRED"
"DOCKING_CLEARANCE_STATUS_GRANTED"
"DOCKING_CLEARANCE_STATUS_TIMING_OUT"
legalStatus
legalStatus : String (read-only)
A string describing the player’s legal status for display purposes, based on bounty
. In English, this is one of "Clean"
(bounty = 0), "Offender"
(0 < bounty ≤ 50) or "Fugitive"
, but note that it can be localized.
name
name : String (read-only)
The name of the player’s character (e.g., “Jameson”).
passengerReputation
passengerReputation : Number (read-only integer)
The player’s passenger contract reputation, ranging from -7 to +7. Reputation is based on fulfilled and unfulfilled contracts. Both individually ranging from 0 till 7. Both good and bad value erode away in time towards 0. All individually values below 7 are seen as unknown reputation. This unknown part is randomised based on the market situation.
See also: contractReputation()
, decreasePassengerReputation()
, increasePassengerReputation()
rank
rank : String (read-only)
A string describing the player’s rank for display purposes, based on score
, such as "Mostly Harmless"
or "Dangerous"
. Note that it can be localized.
score
score : Number (read/write, integer)
The player’s score; nominally the number of kills the player has made, although some missions award additional points.
trumbleCount
trumbleCount : Number (read-only nonnegative integer)
The number of trumbles the player is currently blessed with.
Methods
addMessageToArrivalReport
function addMessageToArrivalReport(message : String)
Adds a message to the arrival report. This is the report shown immediately after docking. Oolite is putting its own stuff on the list immediately after shipWillDockAtStation() so it will be a good moment to add the messages at that moment when you know what station will be docked. At shipDockedWithStation() it will be to late as the report is already being shown at that moment. Messages added will be on the list above oolites own arrival messages. Messages added on the list other than during shipWillDockAtStation() will trigged the report screen when using the F5 screen during flight. This will be fixed in future versions but for now, only add them at shipWillDockAtStation().
commsMessage
function 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. Example: player.commsMessage("Hello, cruel universe.", 6)
NB. This commsMessage() is a property of "player". "player.ship" has also a commsMessage() property, but that belongs to ship and has a different second parameter. (see Oolite JavaScript Reference: Ship)
consoleMessage
function 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.
decreaseContractReputation
function decreaseContractReputation()
Give the player a negative reputation point for cargo contracts. Decreases the underlying value for contractReputation by 1 until a minimum of -7. Depending on the randomised part of the value can the visible value stay the same in one system.
See also: contractReputation
, increaseContractReputation()
decreasePassengerReputation
function decreasePassengerReputation()
Give the player a negative reputation point for passenger contracts. Decreases the underlying value for passengerReputation by 1 until a minimum of -7. Depending on the randomised part of the value can the visible value stay the same in one system.
See also: passengerReputation
, increasePassengerReputation()
increaseContractReputation
function increaseContractReputation()
Give the player a positive reputation point for cargo contracts. Increases the underlying value for contractReputation by 1 until a maximum of 7
See also: contractReputation
, decreaseContractReputation()
increasePassengerReputation
function increasePassengerReputation()
Give the player a positive reputation point for passenger contracts. Increases the underlying value for passengerReputation by 1 until a maximum of 7
See also: passengerReputation
, decreasePassengerReputation()
setEscapePodDestination
This method was added in Oolite beta release 1.75.
function setEscapePodDestination(destination)
This method can only be called after the player has launched an escape pod – for example, from the escapePodSequenceOver()
event handler. It determines where the player will end up. destination
may be any carrier/station entity, or the string "NEARBY_SYSTEM"
, or null
. If it is "NEARBY_SYSTEM"
, the player will end up at the main station in a random nearby system. If it is null
, the player will die of life support failure. (null
is the default in interstellar space.)