Oolite JavaScript Reference: System
Prototype: Object
Subtypes: none
The System
class represents the current system. There is always one System
object, available through the global propery system
.
Attempts to change system properties are ignored in interstellar space (i.e., the place you end up in after a witchspace malfunction).
Contents
Properties
allShips
This property was added in Oolite test release 1.70.
allShips : Array (read-only)
A list of the ships in the system. If there are none, an empty list.
See Also: shipsWithPrimaryRole()
, shipsWithRole()
, entitiesWithScanClass()
, filteredEntities()
.
description
description : String (read/write)
The description of the current system, as seen on the planet info screen.
economy
economy : Number (integer, read/write)
The type of economy in the current system, ranging from 0 (Rich Industrial) to 7 (Poor Agricultural). (See also: economyDescription
)
economyDescription
economyDescription : String (read-only)
A description of the economy type, for example, “Mostly Industrial”. (See also: economy
)
goingNova
goingNova : Boolean (read-only)
true
if the system’s sun is in the process of going nova, false
otherwise. (To do: this should be a propery of the sun.) (See also: goneNova
, setSunNova()
)
goneNova
goneNova : Boolean (read-only)
true
if the system’s sun hase gone nova, false
otherwise. (To do: this should be a propery of the sun.) (See also: goingNova
, setSunNova()
)
government
government : Number (read/write, integer)
The type of government in the current system, ranging from 0 (Anarchy) to 7 (Corporate State). (See also: governmentDescription
)
governmentDescription
governmentDescription : String (read-only)
A description of the government type, for example, “Democracy”. (See also: government
)
ID
ID : Number (integer, read-only)
A number identifying the system. 0 to 255, or -1 for interstellar space. Equivalent to planet_number
in plist scripts.
inhabitantsDescription
inhabitantsDescription : String (read/write)
The description of the inhabitants of the current system, such as “Slimy Blue Frogs”.
isInterstellarSpace
This property was added in Oolite test release 1.70.
isInterstellarSpace : Boolean (read-only)
true
if the current system is in interstellar space, false
otherwise.
mainPlanet
This property was added in Oolite test release 1.70.
mainPlanet : Planet (read-only)
The system’s main planet, or null
if there is none.
mainStation
This property was added in Oolite test release 1.70.
mainStation : Station (read-only)
The system’s main station, or null
if there is none.
planets
This property was added in Oolite test release 1.70.
planets : Array (read-only)
A list of the planets in the system. If there are none, an empty list.
population
population : Number (integer, read/write)
The population of the current system.
productivity
productivity : Number (integer, read/write)
The productivity of the current system.
sun
This property was added in Oolite test release 1.70.
sun : Sun (read-only)
The system’s sun, or null
if there is none.
techLevel
techLevel : Number (integer, read/write)
The technology level of the current system, ranging from 0 to 15.
Methods
addMoon
function addMoon(planetInfoKey : String)
Adds a moon to the system, using the specified entry in planetinfo.plist. A moon is the same as a planet, except that it has no atmosphere. (See also: addPlanet()
)
addPlanet
function addPlanet(planetInfoKey : String)
Adds a planet to the system, using the specified entry in planetinfo.plist. (See also: addMoon()
)
countShipsWithRole
function countShipsWithRole(role : String) : Number (integer)
Returns the number of ships with the specified role in the system; equivalent to checkForShips: in plist scripts.
entitiesWithScanClass
This method was added in Oolite test release 1.70.
function entitiesWithScanClass(scanClass : String [, relativeTo : Entity [, range : Number]]) : Array
A list of the entities in the system whose scan class is scanClass
. If relativeTo
is specified, the list will be sorted in order of proximity to relativeTo
(i.e., the first element of the list is closest). If range
is also specified, entities further than range
metres from relativeTo
will be excluded. If no matching entities are found, an empty array is returned.
See Also: shipsWithPrimaryRole()
, shipsWithRole()
, filteredEntities()
.
filteredEntities
This method was added in Oolite test release 1.70.
function filteredEntities(this : Object, predicate : Function [, relativeTo : Entity [, range : Number]]) : Array
A list of the entities for which predicate
returns true
. If relativeTo
is specified, the list will be sorted in order of proximity to relativeTo
(i.e., the first element of the list is closest). If range
is also specified, entities further than range
metres from relativeTo
will be excluded. If no matching entities are found, an empty array is returned.
Example:
this.findIdlePoliceInScannerRange = function() { function isIdlePolice(entity) { return entity.isShip && entity.isPolice && !entity.target } return system.filteredEntities(this, isIdlePolice, player, 25600) }
See Also: shipsWithPrimaryRole()
, shipsWithRole()
, entitiesWithScanClass()
.
legacy_addShips etc.
function legacy_addShips(role : String, count : Number) function legacy_addSystemShips(role : String, count : Number, position : Number) function legacy_addShipsAt(role : String, count : Number, coordscheme : String, where : vectorExpression) function legacy_addShipsAtPrecisely(role : String, count : Number, coordscheme : String, where : vectorExpression) function legacy_addShipsWithinRadius(role : String, count : Number, coordScheme : String, where : vectorExpression, radius : Number) function legacy_spawn(role : String, count : Number) function legacy_spawnShip(shipDataKey : String)
Various ways of causing ships to appear. Each of these corresponds to a legacy scripting method. A new, more flexible addShips()
function will supersede all of them.
sendAllShipsAway
function sendAllShipsAway()
Makes all ships hyperspace out of the system.
setSunNova
function setSunNova(secondsUntilNova : Number)
Sets the system’s sun to go nova after the specified time interval. Time is specified in game real time.
shipsWithPrimaryRole
This method was added in Oolite test release 1.70.
function shipsWithPrimaryRole(role : String [, relativeTo : Entity [, range : Number]]) : Array
A list of the entities in the system whose primary role is role
. If relativeTo
is specified, the list will be sorted in order of proximity to relativeTo
(i.e., the first element of the list is closest). If range
is also specified, entities further than range
metres from relativeTo
will be excluded. If no matching entities are found, an empty array is returned.
See Also: shipsWithRole()
, entitiesWithScanClass()
, filteredEntities()
.
shipsWithRole
This method was added in Oolite test release 1.70.
function shipsWithRole(role : String [, relativeTo : Entity [, range : Number]]) : Array
A list of the entities in the system whose role set contains role
. If relativeTo
is specified, the list will be sorted in order of proximity to relativeTo
(i.e., the first element of the list is closest). If range
is also specified, entities further than range
metres from relativeTo
will be excluded. If no matching entities are found, an empty array is returned.
See Also: shipsWithRole()
, entitiesWithScanClass()
, filteredEntities()
.