Oolite JavaScript Reference: Station

From Elite Wiki
Revision as of 17:26, 1 December 2014 by Cim (talk | contribs) (allegiance: clarify)

Prototype: Ship
Subtypes: none

The Station class is an Entity representing a station or carrier (i.e., a ship with a docking port). A Station has all the properties and methods of a Ship, and some others.

Properties

alertCondition

alertCondition : Number (read/write, integer)

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

allegiance

This property was added in Oolite test release 1.79.

allegiance : String (read/write)

A string which provides a hint to the AI about the likely response to approaching this station. The following values are recognised by the standard AIs in 1.79

  • hunter : this station is friendly to bounty hunters and hostile to offenders and fugitives
  • galcop : this is the main station or one with similar behaviour
  • neutral : pirates and criminals will not dock here, but may hang around outside safely. Everyone else may dock
  • pirate : pirates and criminals can dock here, while others may get a hostile response
  • chaotic : anyone will be allowed to dock here
  • thargoid : this station is controlled by the Thargoids and is hostile to all Cooperative ships
  • private : this station will refuse docking except to specifically authorised ships. Core Oolite AIs will assume that any station with an unrecognised allegiance is equivalent to private.
  • restricted : this station will refuse docking to and probably fire upon all unauthorised ships

Stations without an allegiance specified when they are created will have a guess made dependent on their legal status, armament and scan class.

allowsAutoDocking

allowsAutoDocking : Boolean (read/write)

If true, the player may dock with this station using autopilot (assuming it isn’t hostile). The corresponding shipdata.plist key is allows_auto_docking (default: true).

allowsFastDocking

allowsFastDocking : Boolean (read/write)

If true, the player may dock with this station instantaneously (assuming it isn’t hostile). The corresponding shipdata.plist key is allows_fast_docking (default: false, but set to true when setting up the main station).

breakPattern

This property was added in Oolite test release 1.77.

breakPattern : Boolean (read/write)

If true (the default state), the break pattern defined in shipdata.plist will be shown when launching or docking.

dockedContractors

dockedContractors : Number (read-only, integer)

Returns the number of docked contractors ships that can launch as miner or scavenger.
There is only one counter for miners and scavengers. The maximum that can launch as miner/scavenger is determined by the shipdata-key max_scavengers. However, miners can only launch when there is no other miner in the stations scanner range, even when contractor ships are docked.

dockedDefenders

dockedDefenders : Number (read-only, integer)

Returns the number of docked defence ships that can launch as defence ships.
There is only one counter for defence and police ships. However, the maximum that can launch as defenders is determined by the shipdata-key max_defense_ships.

dockedPolice

dockedPolice : Number (read-only, integer)

Returns the number of docked defence ships that can launch as police or patrol ships.
There is only one counter for defence and police ships. However, the maximum that can launch as police/patrol is determined by the shipdata-key max_police.

equipmentPriceFactor

equipmentPriceFactor : Number (read-only, float)

Returns the equipment_price_factor for the station as defined in shipdata.plist.

equivalentTechLevel

equivalentTechLevel : Number (read-only, Integer)

Returns the equivalent_tech_level for the station as defined in shipdata.plist.

hasNPCTraffic

hasNPCTraffic : Boolean (read/write)

If true, the station has associated non-player traffic, such as shuttles, patrol ships and scavengers. Corresponds to the has_npc_traffic shipdata.plist key.

hasShipyard

This property was added in Oolite test release 1.77.

hasShipyard : Boolean (read-only)

If true, the station has a shipyard where the player may trade in their ship. Corresponds to the has_shipyard shipdata.plist key.

isMainStation

isMainStation : Boolean (read-only)

true if the station is the main station of the system, false otherwise.

market

This property was added in Oolite test release 1.77.

market : Object (read-only)

An object with one property for each commodity in the game. Each property has a read-only object as its value, reflecting the commodities.plist entry for this station, and the current market state. For example:

computers: {
       marketMaskPrice: "3",
       marketEcoAdjustPrice: "14",
       price: 900,
       quantityUnit: "0",
       marketMaskQuantity: "3",
       marketBaseQuantity: "56",
       marketEcoAdjustQuantity: "14",
       marketBasePrice: "154",
       quantity: 0,
       displayName: "Computers"
}

price is measured in decicredits, and quantity in the units determined by quantityUnit.

In 1.79 or later there is also a "legalPenalty" entry describing the export bounty applied per unit for this cargo at main stations.

requiresDockingClearance

requiresDockingClearance : Boolean (read/write)

true if the station requires docking clearance, false otherwise.

roll

This property was added in Oolite test release 1.77.

roll : Number (read/write)

The rate of roll of the station in radians/second (positive for anti-clockwise, negative for clockwise)

For stations, this can be set to any value between -2 and +2 to adjust their roll rate. The default is 0.4, or the value specified by the station_roll key in shipdata.plist. (Note that the station_roll property is for historical reasons in right-angles/second, not radians/second, so the reported value of station.roll will not be numerically equal to the shipdata.plist station_roll property)


suppressArrivalReports

suppressArrivalReports : Boolean (read/write)

If set to true, arrival reports are not shown when the player docks with the station.

Methods

abortAllDockings

This method was added in Oolite test release 1.79.

abortAllDockings()

Removes docking clearance from all ships currently waiting to dock. Their AIs will receive a message.

abortDockingForShip

This method was added in Oolite test release 1.79.

abortDockingForShip(ship)

Removes docking clearance from the specified ship if it is currently waiting to dock.

dockPlayer

dockPlayer() : Boolean 

This method docks the player at the specified station. Returns false if docking fails, otherwise true.

launchDefenseShip

launchDefenseShip() : Ship 

This method adds a ship with a role defined in the ship key "defense_ship_role" or a specific ship defined with a ship key "defense_ship", to the launching queue at the specified station. When no defense ships are defined it selects one from the police or interceptors. All ships launch with a primary role of "defense_ship". Returns the entity of the chosen ship. This method aborts all dockings for an immediate launch.

launchEscort

This method was added in Oolite test release 1.79.

launchEscort() : Ship 

This method adds a ship with an "escort" role to the launching queue, and returns the ship. This ship is not an escort of the station itself - it will need to find a suitable mothership to escort once launched.

launchMiner

launchMiner() : Ship 

This method adds a ship with a miner role to the launching queue at the specified station. Launches only a miner when there is a contractor ship at the station and when the number of miners around the station is zero. (there can only be one!) Returns the entity of the chosen ship.

launchPatrol

launchPatrol() : Ship 

This method adds a ship with a police role and planetPatrolAI.plist to the launching queue at the specified station. Returns the entity of the chosen ship.

launchPirateShip

launchPirateShip() : Ship 

This method adds a ship with a pirate role to the launching queue at the specified station. All ships launch with a primary role of "defense_ship" and pirateAI.plist. These pirate ships are counted as defense_ship. Returns the entity of the chosen ship.

launchPolice

launchPolice() : Array 

This method adds up to 4 police ships to the launching queue at the specified station. Returns an array of chosen police ships. Depending on the system it selects ships with role police or interceptor, but on launch all primary roles will be police
It will only launch a ship if the station has a target and there are police ships left. This method aborts all dockings for an immediate launch.

launchScavenger

launchScavenger() : Ship 

This method adds a ship with a scavenger role to the launching queue at the specified station. Launches only a scavenger when there is a contractor ship at the station and when the number of scavengers around the station is less than the maximum number of scavengers. Returns the entity of the chosen ship.

launchShipWithRole

launchShipWithRole(role : String, [abortAllDockings : Boolean]) : Ship 

This method adds a ship with given role to the launching queue at the specified station. Returns the entity of the chosen ship.
When abortAllDockings is true (default: false), all ships in the docking process get an abort message and launching of ships starts immediately. Don't use this parameter when not strictly necessary for your launching ship.

launchShuttle

launchShuttle() : Ship 

This method adds a ship with a shuttle role to the launching queue at the specified station. Returns the entity of the chosen ship.

setInterface

This method was added in Oolite test release 1.77.

setInterface(key : String, interfaceDefinition : Object)

This method sets the station interface definition for the specified key (or removes that definition, if the interfaceDefinition is null). Interface definition objects have the following required properties:

  • title: (short) String: the title displayed in the interface list.
  • category: (short) String: the category displayed and used to sort the interface list.
  • summary: String: the summary text displayed below the interface list when this interface is selected.
  • callback: Function: the function that will be called when this interface is activated. This callback can safely and generally will call mission.runScreen. The callback function will be passed the interface key as a parameter, so you can use the same callback for multiple interface entries if necessary.

and the following optional properties:

  • cbThis: Script: the script that will act as 'this' when the callback runs. This can be omitted if you use the bind method.

As the key must be unique, it is strongly recommended to prefix it with an OXP-specific string.

For example:

station.setInterface("my-oxp-example1",{
  title: "Example title",
  category: "Examples",
  summary: "This is an example interface definition. Further information is available.",
  callback: this._furtherExampleInformation.bind(this)
});

or

// the player has accepted the mission, so remove the interface
station.setInterface("my-oxp-example2",null);

setMarketPrice

This method was added in Oolite test release 1.77.

setMarketPrice(commodity : String, price : Number)

Set the price of the specified commodity in the local station market to the given value. For example:

station.setMarketPrice("food",38);

The price is in decicredits, and must be between 0 and 1020 decicredits.

setMarketQuantity

This method was added in Oolite test release 1.77.

setMarketQuantity(commodity : String, quantity : Number)

Set the quantity of the specified commodity in the local station market to the given value. For example:

station.setMarketQuantity("machinery",15);

The quantity is in units, and must be between 0 and 127 units.