Difference between revisions of "Oolite JavaScript Reference: PlayerShip"

From Elite Wiki
(Added manifest)
Line 17: Line 17:
  
 
'''See also''': <code>[[#aftShield|aftShield]]</code>, <code>[[#forwardShieldRechargeRate|forwardShieldRechargeRate]]</code>, <code>[[#maxAftShield|maxAftShield]]</code>
 
'''See also''': <code>[[#aftShield|aftShield]]</code>, <code>[[#forwardShieldRechargeRate|forwardShieldRechargeRate]]</code>, <code>[[#maxAftShield|maxAftShield]]</code>
 +
 +
=== <code>aftWeapon</code> ===
 +
{{Oolite-prop-added|1.74}}
 +
'''aftWeapon''' : EquipmentType(read-only)
 +
The currently equipped aft weapon, or null.<br>Example usage:
 +
if (!player.ship.aftWeapon) consoleMessage('Time to buy an aft weapon, commander!');
 +
 +
'''See also''': <code>[[#forwardWeapon|forwardWeapon]]</code>, <code>[[#portWeapon|portWeapon]]</code><code>, [[#starboardWeapon|starboardWeapon]]</code>
 +
 +
=== <code>compassMode</code> ===
 +
{{Oolite-prop-added|1.74}}
 +
'''compassMode''' : String (read-only)
 +
Returns the current compass mode, which can be any one of the following:
 +
 +
COMPASS_MODE_BASIC
 +
COMPASS_MODE_PLANET
 +
COMPASS_MODE_STATION
 +
COMPASS_MODE_SUN
 +
COMPASS_MODE_TARGET
 +
COMPASS_MODE_BEACONS
 +
 +
=== <code>compassTarget</code> ===
 +
{{Oolite-prop-added|1.74}}
 +
'''compassTarget''' : Entity(read-only)
 +
Points at the entity currently targeted by the compass.
  
 
=== <code>cursorCoordinates</code> ===
 
=== <code>cursorCoordinates</code> ===
Line 42: Line 67:
  
 
'''See also''': <code>[[#aftShieldRechargeRate|aftShieldRechargeRate]]</code>, <code>[[#forwardShield|forwardShield]]</code>, <code>[[#maxForwardShield|maxForwardShield]]</code>
 
'''See also''': <code>[[#aftShieldRechargeRate|aftShieldRechargeRate]]</code>, <code>[[#forwardShield|forwardShield]]</code>, <code>[[#maxForwardShield|maxForwardShield]]</code>
 +
 +
=== <code>forwardWeapon</code> ===
 +
{{Oolite-prop-added|1.74}}
 +
'''forwardWeapon''' : EquipmentType(read-only)
 +
The currently equipped forward weapon, or null.<br>Example usage:
 +
if (player.ship.forwardWeapon.equipmentKey == 'EQ_WEAPON_PULSE_LASER')
 +
              consoleMessage('Time to upgrade your pulse laser, commander!');
 +
 +
'''See also''': <code>[[#aftWeapon|aftWeapon]]</code>, <code>[[#portWeapon|portWeapon]]</code><code>, [[#starboardWeapon|starboardWeapon]]</code>
  
 
=== <code>fuelLeakRate</code> ===
 
=== <code>fuelLeakRate</code> ===
Line 77: Line 111:
 
  '''maxAftShield''' : Number (read-only, nonnegative)
 
  '''maxAftShield''' : Number (read-only, nonnegative)
 
The highest possible value of <code>[[#aftShield|aftShield]]</code>. This is affected by equipment – currently the Shield Boosters and Military Shield Enhancement. Currently always the same as <code>[[#maxForwardShield|maxForwardShield]]</code>, but this may change in future.
 
The highest possible value of <code>[[#aftShield|aftShield]]</code>. This is affected by equipment – currently the Shield Boosters and Military Shield Enhancement. Currently always the same as <code>[[#maxForwardShield|maxForwardShield]]</code>, but this may change in future.
 
  
 
'''See also''': <code>[[#aftShield|aftShield]]</code>, <code>[[#aftShieldRechargeRate|aftShieldRechargeRate]]</code>, <code>[[#maxForwardShield|maxForwardShield]]</code>
 
'''See also''': <code>[[#aftShield|aftShield]]</code>, <code>[[#aftShieldRechargeRate|aftShieldRechargeRate]]</code>, <code>[[#maxForwardShield|maxForwardShield]]</code>
Line 86: Line 119:
  
 
'''See also''': <code>[[#forwardShield|forwardShield]]</code>, <code>[[#forwardShieldRechargeRate|forwardShieldRechargeRate]]</code>, <code>[[#maxAftShield|maxAftShield]]</code>
 
'''See also''': <code>[[#forwardShield|forwardShield]]</code>, <code>[[#forwardShieldRechargeRate|forwardShieldRechargeRate]]</code>, <code>[[#maxAftShield|maxAftShield]]</code>
 +
 +
=== <code>portWeapon</code> ===
 +
{{Oolite-prop-added|1.74}}
 +
'''portWeapon''' : EquipmentType(read-only)
 +
The currently equipped port weapon, or null.
 +
 +
'''See also''': <code>[[#aftWeapon|aftWeapon]]</code>, <code>[[#forwardWeapon|forwardWeapon]]</code>, <code>[[#starboardWeapon|starboardWeapon]]</code>
  
 
=== <code>reticleTargetSensitive</code> ===
 
=== <code>reticleTargetSensitive</code> ===
Line 101: Line 141:
  
 
'''See also''': <code>[[#useSpecialCargo|useSpecialCargo]]()</code>
 
'''See also''': <code>[[#useSpecialCargo|useSpecialCargo]]()</code>
 +
 +
=== <code>starboardWeapon</code> ===
 +
{{Oolite-prop-added|1.74}}
 +
'''starboardWeapon''' : EquipmentType(read-only)
 +
The currently equipped port weapon, or null.
 +
 +
'''See also''': <code>[[#aftWeapon|aftWeapon]]</code>, <code>[[#forwardWeapon|forwardWeapon]]</code>, <code>[[#portWeapon|portWeapon]]</code>
  
  
 
== Methods ==
 
== Methods ==
=== <code>awardCargo</code> ===
+
=== <code>awardCargo (deprecated)</code> ===
 
  function '''awardCargo'''(cargoname : String, amount : Number)
 
  function '''awardCargo'''(cargoname : String, amount : Number)
 
Awards the given amount of the specified type of cargo. The cargo name must match the name in ''commodities.plist'' exactly.
 
Awards the given amount of the specified type of cargo. The cargo name must match the name in ''commodities.plist'' exactly.
 +
 +
This function is deprecated in 1.74 - use specific [[Oolite JavaScript Reference: Manifest|Manifest]] properties instead.
  
 
=== <code>awardEquipment</code> ===
 
=== <code>awardEquipment</code> ===
Line 112: Line 161:
 
Adds the given piece of equipment to the player’s ship. Example: <code>player.awardEquipment("EQ_TRUMBLE")</code>
 
Adds the given piece of equipment to the player’s ship. Example: <code>player.awardEquipment("EQ_TRUMBLE")</code>
  
=== <code>canAwardCargo</code> ===
+
=== <code>canAwardCargo (deprecated)</code> ===
 
  function '''canAwardCargo'''(cargoName : String, amount : Number) : Boolean
 
  function '''canAwardCargo'''(cargoName : String, amount : Number) : Boolean
 
Returns <code>true</code> if it is possible to add the specified cargo to the ship, <code>false</code> otherwise. In particular, it will return <code>false</code> if there is not enough space, if the cargo type is unknown or if there is currently special cargo installed (and the cargo is of a type measured in tons). Attempting to award cargo under these conditions will raise an error, so using <code>canAwardCargo</code> is strongly recommended.
 
Returns <code>true</code> if it is possible to add the specified cargo to the ship, <code>false</code> otherwise. In particular, it will return <code>false</code> if there is not enough space, if the cargo type is unknown or if there is currently special cargo installed (and the cargo is of a type measured in tons). Attempting to award cargo under these conditions will raise an error, so using <code>canAwardCargo</code> is strongly recommended.
 +
 +
This function is deprecated in 1.74 in favour of the more direct [[Oolite JavaScript Reference: Manifest|Manifest]] properties.
  
 
'''See also:''' <code>[[#awardCargo|awardCargo]]()</code>
 
'''See also:''' <code>[[#awardCargo|awardCargo]]()</code>

Revision as of 15:07, 11 December 2009

Prototype: Ship

This class was added in Oolite test release 1.72.

The PlayerShip class is an Entity representing the player’s ship. The PlayerShip has all the properties and methods of a Ship, and several others.

Properties

aftShield

aftShield : Number (read/write, nonnegative)

The current aft shield level, ranging from 0 to maxAftShield.

See also: aftShieldRechargeRate, forwardShield, maxAftShield

aftShieldRechargeRate

aftShieldRechargeRate : Number (read-only, nonnegative)

The rate at which the aft shield recharges (assuming enough energy is available). This is affected by equipment – currently, the Military Shield Enhancement. Currently always the same as forwardShieldRechargeRate, but this may change in future.

See also: aftShield, forwardShieldRechargeRate, maxAftShield

aftWeapon

This property was added in Oolite test release 1.74.

aftWeapon : EquipmentType(read-only)

The currently equipped aft weapon, or null.
Example usage:

if (!player.ship.aftWeapon) consoleMessage('Time to buy an aft weapon, commander!');

See also: forwardWeapon, portWeapon, starboardWeapon

compassMode

This property was added in Oolite test release 1.74.

compassMode : String (read-only)

Returns the current compass mode, which can be any one of the following:

COMPASS_MODE_BASIC
COMPASS_MODE_PLANET
COMPASS_MODE_STATION
COMPASS_MODE_SUN
COMPASS_MODE_TARGET
COMPASS_MODE_BEACONS

compassTarget

This property was added in Oolite test release 1.74.

compassTarget : Entity(read-only)

Points at the entity currently targeted by the compass.

cursorCoordinates

This property was added in Oolite test release 1.73.

cursorCoordinates : Vector2D (read-only)

Gives the current x and y cursor Coordinates on the long range screen. The z coordinate is always 0.

docked

docked : Boolean (read-only)

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

dockedStation

dockedStation : Station (read-only)

The station with which the player is currently docked.

forwardShield

forwardShield : Number (read/write, nonnegative)

The current forward shield level, ranging from 0 to maxForwardShield.

See also: aftShield, forwardShieldRechargeRate, maxForwardShield

forwardShieldRechargeRate

forwardShieldRechargeRate : Number (read-only, nonnegative)

The rate at which the forward shield recharges (assuming enough energy is available). This is affected by equipment – currently, the Military Shield Enhancement. Currently always the same as aftShieldRechargeRate, but this may change in future.

See also: aftShieldRechargeRate, forwardShield, maxForwardShield

forwardWeapon

This property was added in Oolite test release 1.74.

forwardWeapon : EquipmentType(read-only)

The currently equipped forward weapon, or null.
Example usage:

if (player.ship.forwardWeapon.equipmentKey == 'EQ_WEAPON_PULSE_LASER')
             consoleMessage('Time to upgrade your pulse laser, commander!');

See also: aftWeapon, portWeapon, starboardWeapon

fuelLeakRate

fuelLeakRate : Number (read/write)

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.

galacticHyperspaceBehaviour

This property was added in Oolite test release 1.72.1.

galacticHyperspaceBehaviour : String (read/write)

A string indicating what the effect of a galactic hyperspace jump will be. The available options are:

  • "BEHAVIOUR_STANDARD": the player arrives in the closest system to the starting point that is part of the main group of stars. Small groups (as seen in galaxy 6, among others) can’t be reached.
  • "BEHAVIOUR_ALL_SYSTEMS_REACHABLE": The player arrives at the closest system to the starting point, even if it is in a small group. Important: this can leave the player stranded, unless there are missions providing the possibility of escape!
  • "BEHAVIOUR_FIXED_COORDINATES": The player arrives at the system closest to galacticHyperspaceFixedCoords.

See also: galacticHyperspaceFixedCoords,

galacticHyperspaceFixedCoords

This property was added in Oolite test release 1.72.1.

galacticHyperspaceFixedCoords : Vector3D (read/write)

The destination coordinates when galacticHyperspaceBehaviour mode is "GALACTIC_HYPERSPACE_BEHAVIOUR_FIXED_COORDINATES". The z coordinate will always be 0, and x and y will always be integers ranging from 0 to 255.

See also: galacticHyperspaceBehaviour

galaxyCoordinates

This property was added in Oolite test release 1.73.

galaxyCoordinates : Vector3D (read-only)

Gives the current x and y galactic coordinates. The z coordinate is always 0.

manifest

This property was added in Oolite test release 1.74.

manifest : Manifest (read/write)

The manifest contains all the cargo the player carries. It can be addressed as a property of playerShip as well as a class Manifest of its own.

maxAftShield

maxAftShield : Number (read-only, nonnegative)

The highest possible value of aftShield. This is affected by equipment – currently the Shield Boosters and Military Shield Enhancement. Currently always the same as maxForwardShield, but this may change in future.

See also: aftShield, aftShieldRechargeRate, maxForwardShield

maxForwardShield

maxAftShield : Number (read-only, nonnegative)

The highest possible value of forwardShield. This is affected by equipment – currently the Shield Boosters and Military Shield Enhancement. Currently always the same as maxAftShield, but this may change in future.

See also: forwardShield, forwardShieldRechargeRate, maxAftShield

portWeapon

This property was added in Oolite test release 1.74.

portWeapon : EquipmentType(read-only)

The currently equipped port weapon, or null.

See also: aftWeapon, forwardWeapon, starboardWeapon

reticleTargetSensitive

reticleTargetSensitive : Boolean (read/write)

If true, and Scanner Targeting Enhancement is installed, the selected target reticle will light up in red when the target is in the player’s sights. This is equivalent to the reticle_target_sensitive key in HUD plists.

scriptedMisjump

This property was added in Oolite test release 1.73.

scriptedMisjump : Boolean (read/write)

When true, the next hyperspace jump will be a misjump. Scripted misjumps have a lifespan of one jump only, then they are autoreset. The scripted_misjump flag will remain set to true during the shipWillExitWitchspace handler, but will be back to false at the end of the shipExitedWitchspace handler

specialCargo

specialCargo : String (read-only)

The special cargo the player is carrying, if any; otherwise null.

See also: useSpecialCargo()

starboardWeapon

This property was added in Oolite test release 1.74.

starboardWeapon : EquipmentType(read-only)

The currently equipped port weapon, or null.

See also: aftWeapon, forwardWeapon, portWeapon


Methods

awardCargo (deprecated)

function awardCargo(cargoname : String, amount : Number)

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

This function is deprecated in 1.74 - use specific Manifest properties instead.

awardEquipment

function awardEquipment(equipmentKey : String)

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

canAwardCargo (deprecated)

function canAwardCargo(cargoName : String, amount : Number) : Boolean

Returns true if it is possible to add the specified cargo to the ship, false otherwise. In particular, it will return false if there is not enough space, if the cargo type is unknown or if there is currently special cargo installed (and the cargo is of a type measured in tons). Attempting to award cargo under these conditions will raise an error, so using canAwardCargo is strongly recommended.

This function is deprecated in 1.74 in favour of the more direct Manifest properties.

See also: awardCargo()

equipmentStatus

function equipmentStatus(equipmentKey : String) : String

Tests whether the specified type of equipment is installed, and whether it is functioning. Returns one of the following strings: "EQUIPMENT_OK", "EQUIPMENT_DAMAGED", "EQUIPMENT_UNAVAILABLE".

See also: setEquipmentStatus()

hasEquipment

Moved to Ship in 1.73.

launch

function launch()

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

removeAllCargo

function removeAllCargo()

Removes all cargo from the ship’s cargo bay.

removeEquipment

function removeEquipment(equipmentKey : String)

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

setEquipmentStatus

function setEquipmentStatus(equipmentKey : String, statusKey : String)

Changes the status of the given piece of equipment from the player’s ship. The two only valid status keys are "EQUIPMENT_OK", "EQUIPMENT_DAMAGED".

See also: equipmentStatus()

useSpecialCargo

function useSpecialCargo(description : String)

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

See also: specialCargo