Oolite JavaScript Reference: Station (AI Readable Version)
From Elite Wiki
### `Station` (Ship)
* **Description**: A `Station` is a type of `Ship` that has a docking port, such as a space station or a carrier. It inherits all properties and methods from the `Ship` class and adds several of its own.
---
### **Properties**
* **.alertCondition** (Number, Read/Write): The station's current alert condition: 1 = Green, 2 = Yellow, 3 = Red.
* **.allegiance** (String, Read/Write): A hint to AIs about the station's affiliation (e.g., `"galcop"`, `"pirate"`, `"private"`). This determines which ships are allowed to dock or are treated with hostility.
* **.allowsAutoDocking** (Boolean, Read/Write): If `true`, a player with a Docking Computer can use the autopilot to dock.
* **.allowsFastDocking** (Boolean, Read/Write): If `true`, a player with a Docking Computer can use the fast-dock key (Shift-C) to dock instantly.
* **.breakPattern** (Boolean, Read/Write): If `true` (the default), the visual break pattern is shown when ships launch or dock.
* **.dockedContractors** (Number, Read-only): The number of docked contractor ships available to launch as miners or scavengers.
* **.dockedDefenders** (Number, Read-only): The number of docked ships available to launch as defenders.
* **.dockedPolice** (Number, Read-only): The number of docked ships available to launch as police or patrol vessels.
* **.equipmentPriceFactor** (Number, Read-only): The price multiplier for equipment sold at this station, defined in `shipdata.plist`.
* **.equivalentTechLevel** (Number, Read-only): The station's effective tech level, defined in `shipdata.plist`.
* **.hasNPCTraffic** (Boolean, Read/Write): If `true`, the station will spawn associated NPC traffic like shuttles and patrol ships.
* **.hasShipyard** (Boolean, Read-only): If `true`, the station has a shipyard where the player can buy and sell ships.
* **.isMainStation** (Boolean, Read-only): `true` if this is the primary station in the system.
* **.market** (Object, Read-only): An object containing the current price and quantity data for all commodities at this station. The format of the data changed significantly in Oolite v1.81.
* **.requiresDockingClearance** (Boolean, Read/Write): `true` if ships must request docking clearance before docking.
* **.roll** (Number, Read/Write): The station's rate of roll in radians per second, adjustable between -2.0 and +2.0.
* **.shipyard** (Array, Read-only): An array of ship dictionary objects for all ships currently for sale. Returns `null` if there is no shipyard. Each object contains details like `shipdata_key`, `price`, and `extras`.
* **.suppressArrivalReports** (Boolean, Read/Write): If `true`, the arrival report screen is not shown when the player docks.
---
### **Methods**
* **abortAllDockings()**
* **Description**: Revokes docking clearance for all ships currently in the docking queue. Their AIs will receive a message.
* **Signature**: `()`
* **abortDockingForShip(ship)**
* **Description**: Revokes docking clearance for a specific ship.
* **Signature**: `(ship: Ship)`
* **addShipToShipyard(dictionary)**
* **Description**: Adds a new ship to the station's shipyard for sale. The provided dictionary must include `shipdata_key` and `price`, and can include `extras` and `personality`.
* **Signature**: `(dictionary: Object)`
* **canDockShip(shipEntity)**
* **Description**: Returns `true` if the provided ship is small enough to fit in the station's dock.
* **Signature**: `(shipEntity: Ship): Boolean`
* **dockPlayer()**
* **Description**: Immediately docks the player's ship at the station. Returns `true` on success, `false` on failure.
* **Signature**: `(): Boolean`
* **launchDefenseShip()**
* **Description**: Launches a defense ship. Aborts all current dockings for an immediate launch. Returns the entity of the chosen ship.
* **Signature**: `(): Ship`
* **launchEscort()**
* **Description**: Launches a ship with the "escort" role. Returns the ship.
* **Signature**: `(): Ship`
* **launchMiner()**
* **Description**: Launches a ship with the "miner" role. Only one miner from a station can be active at a time. Returns the entity of the chosen ship.
* **Signature**: `(): Ship`
* **launchPatrol()**
* **Description**: Launches a police ship with a planetary patrol AI. Returns the entity of the chosen ship.
* **Signature**: `(): Ship`
* **launchPirateShip()**
* **Description**: Launches a pirate ship, which is counted as a defense ship. Returns the entity of the chosen ship.
* **Signature**: `(): Ship`
* **launchPolice()**
* **Description**: Launches up to four police ships. Aborts all current dockings for an immediate launch. Returns an array of chosen police ships.
* **Signature**: `(): Array`
* **launchScavenger()**
* **Description**: Launches a ship with the "scavenger" role. Returns the entity of the chosen ship.
* **Signature**: `(): Ship`
* **launchShipWithRole(role, abortAllDockings)**
* **Description**: Launches a ship with a given `role`. If the optional second parameter is `true`, it will abort all current dockings for an immediate launch. Returns the entity of the chosen ship.
* **Signature**: `(role: String, abortAllDockings?: Boolean): Ship`
* **launchShuttle()**
* **Description**: Launches a ship with the "shuttle" role. Returns the entity of the chosen ship.
* **Signature**: `(): Ship`
* **removeShipFromShipyard(shipIndex)**
* **Description**: Removes a ship from the shipyard sale list using its zero-based array index.
* **Signature**: `(shipIndex: Number)`
* **setInterface(key, interfaceDefinition)**
* **Description**: Adds, modifies, or removes a custom screen in the station's F4 interface. The `interfaceDefinition` object requires properties like `title`, `category`, and a `callback` function.
* **Signature**: `(key: String, interfaceDefinition: Object)`
* **setMarketPrice(commodity, price)**
* **Description**: Sets the price for a specific commodity in the station's market. The price is in decicredits (tenths of a credit).
* **Signature**: `(commodity: String, price: Number)`
* **setMarketQuantity(commodity, quantity)**
* **Description**: Sets the available quantity for a specific commodity in the station's market. The quantity must be between 0 and 127 units.
* **Signature**: `(commodity: String, quantity: Number)`