Difference between revisions of "Oolite JavaScript Reference: SystemInfo"
From Elite Wiki
Eric Walch (talk | contribs) m (→coordinates) |
Eric Walch (talk | contribs) (Added "other properties") |
||
Line 17: | Line 17: | ||
'''systemID''' : Number (read/write nonnegative integer) | '''systemID''' : Number (read/write nonnegative integer) | ||
The ID number of the system. | The ID number of the system. | ||
+ | |||
+ | |||
+ | == More properties == | ||
+ | Additional to these properties you have access to many other system properties, using the same keys as [[planetinfo.plist]]. e.g. | ||
+ | <code>System.info.description = "This is a dull planet."</code> | ||
+ | sets the description of the current planet to "This is a dull planet." | ||
Line 44: | Line 50: | ||
return SystemInfo.filteredSystems(this, function(other) | return SystemInfo.filteredSystems(this, function(other) | ||
{ | { | ||
− | return (other !== thisSystem) && (thisSystem.distanceToSystem(other) <= range); | + | return (other.systemID !== thisSystem.systemID) && (thisSystem.distanceToSystem(other) <= range); |
}); | }); | ||
} | } |
Revision as of 16:38, 30 January 2010
Prototype: Object
This class was added in Oolite test release 1.74.
SystemInfo
objects provide information about a specific system.
Contents
Properties
coordinates
coordinates : Vector (read-only)
The coordinates of the system in light years. e.g. for Lave: (8, 34.6, 0)
. The z component is always zero.
galaxyID
galaxyID : Number (read/write nonnegative integer)
The ID number of the galaxy.
systemID
systemID : Number (read/write nonnegative integer)
The ID number of the system.
More properties
Additional to these properties you have access to many other system properties, using the same keys as planetinfo.plist. e.g.
System.info.description = "This is a dull planet."
sets the description of the current planet to "This is a dull planet."
Methods
distanceToSystem
function distanceToSystem(SystenInfo) : Number
Returns the distance in light year to the other SystemInfo.
systemsInRange
function systemsInRange(Number) : Array
Returns an array of SystemInfos in range. When no distance is defined, 7 is assumed.
Static methods
filteredSystems
function filteredSystems(this : Object, predicate : Function ) : Array of SystemInfo
A list of the SystemInfos for which predicate
returns true
.
Example:
SystemInfo.systemsInRange = function(range) { if (range === undefined) { range = 7; } var thisSystem = system.info; return SystemInfo.filteredSystems(this, function(other) { return (other.systemID !== thisSystem.systemID) && (thisSystem.distanceToSystem(other) <= range); }); }