Difference between revisions of "Oolite JavaScript Reference: Station"
(→setInterface: fix syntax) |
Eric Walch (talk | contribs) (Updated market info) |
||
Line 147: | Line 147: | ||
station.setInterface("my-oxp-example2",null); | station.setInterface("my-oxp-example2",null); | ||
− | === <code> | + | === <code>setMarketPrice</code> === |
{{oolite-method-added|1.77}} | {{oolite-method-added|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: | Set the price of the specified commodity in the local station market to the given value. For example: | ||
− | station. | + | station.setMarketPrice("food",38); |
The price is in decicredits, and must be between 0 and 1020 decicredits. | The price is in decicredits, and must be between 0 and 1020 decicredits. | ||
− | === <code> | + | === <code>setMarketQuantity</code> === |
{{oolite-method-added|1.77}} | {{oolite-method-added|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: | Set the quantity of the specified commodity in the local station market to the given value. For example: | ||
− | station. | + | station.setMarketQuantity("machinery",15); |
The quantity is in units, and must be between 0 and 127 units. | The quantity is in units, and must be between 0 and 127 units. | ||
Revision as of 09:04, 29 December 2012
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.
Contents
- 1 Properties
- 1.1 alertCondition
- 1.2 allowsAutoDocking
- 1.3 allowsFastDocking
- 1.4 breakPattern
- 1.5 dockedContractors
- 1.6 dockedDefenders
- 1.7 dockedPolice
- 1.8 equipmentPriceFactor
- 1.9 equivalentTechLevel
- 1.10 hasNPCTraffic
- 1.11 hasShipyard
- 1.12 isMainStation
- 1.13 market
- 1.14 requiresDockingClearance
- 1.15 suppressArrivalReports
- 2 Methods
Properties
alertCondition
alertCondition : Number (read/write, integer)
Returns the current alert condition. 1 = Green, 2 = Yellow, 3 = Red.
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
.
requiresDockingClearance
requiresDockingClearance : Boolean (read/write)
true
if the station requires docking clearance, false
otherwise.
suppressArrivalReports
suppressArrivalReports : Boolean (read/write)
If set to true
, arrival reports are not shown when the player docks with the station.
Methods
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.
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 callmission.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 thebind
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.