Difference between revisions of "Oolite JavaScript Reference: Planet"

From Elite Wiki
(Removed Oolite 1.75 change notes.)
(Updating BB links)
 
(4 intermediate revisions by 4 users not shown)
Line 5: Line 5:
  
 
== Properties ==
 
== Properties ==
 +
=== <code>airColor</code> ===
 +
{{oolite-prop-added|1.89}}
 +
'''airColor''' : Array (read/write)
 +
The colour of the planets atmosphere. An array of RGBA components, but can be set with any other [[Materials_in_Oolite#Colour_specifiers|colour specifier]].
 +
 +
=== <code>airColorMixRatio</code> ===
 +
{{oolite-prop-added|1.89}}
 +
'''airColorMixRatio''' : Number (read/write)
 +
The amount of air colour that be mixed in the overall atmosphere color. A number from 0.0 to 1.0.
 +
 +
=== <code>airDensity</code> ===
 +
{{oolite-prop-added|1.91}}
 +
'''airDensity''' : Number (read/write)
 +
The density of the planet's atmosphere. A number from 0.0 to 1.0.
 +
 
=== <code>hasAtmosphere</code> ===
 
=== <code>hasAtmosphere</code> ===
 
  '''hasAtmosphere''' : Boolean (read-only)
 
  '''hasAtmosphere''' : Boolean (read-only)
 
<code>true</code> if the entity has an atmosphere, <code>false</code> otherwise. Planets created with the <code>System.[[Oolite/Development/Scripting/Class/System#addMoon|addMoon]]()</code> method (or corresponding legacy scripting method) have no atmosphere, other planets do.
 
<code>true</code> if the entity has an atmosphere, <code>false</code> otherwise. Planets created with the <code>System.[[Oolite/Development/Scripting/Class/System#addMoon|addMoon]]()</code> method (or corresponding legacy scripting method) have no atmosphere, other planets do.
 +
 +
=== <code>illuminationColor</code> ===
 +
{{oolite-prop-added|1.91}}
 +
'''illuminationColor''' : Array (read/write)
 +
The colour of the planet's illumination such as cities light. An array of RGBA components, but can be set with any other [[Materials_in_Oolite#Colour_specifiers|colour specifier]].
 +
 +
'''Note:''' Illumination is inserted as a grayscale map in the alpha channel of the planet's diffuse texture. If no illumination map is defined, then you can still access this property but you will not see any difference by changing it - without an illumination map the dark side of the planet remains dark in all cases.
  
 
=== <code>isMainPlanet</code> ===
 
=== <code>isMainPlanet</code> ===
 
  '''isMainPlanet''' : Boolean (read-only)
 
  '''isMainPlanet''' : Boolean (read-only)
 
<code>true</code> if the entity is the main planet of the current system, <code>false</code> otherwise.
 
<code>true</code> if the entity is the main planet of the current system, <code>false</code> otherwise.
 +
 +
'''See also''': <code>[[Oolite JavaScript Reference: System#mainPlanet|system.mainPlanet]]</code>
 +
 +
=== <code>name</code> ===
 +
{{oolite-prop-added|1.79}}
 +
'''name''' : String (read/write)
 +
The name of the planet, as set by the <code>planet_name</code> property in [[planetinfo.plist]]
 +
 +
For convenience of working with secondary planets, this can be written to by JS. For the system main planet, writing to <code>system.info.planet_name</code> is preferred.
  
 
=== <code>radius</code> ===
 
=== <code>radius</code> ===
Line 27: Line 58:
  
 
The name of the texture file (diffuse map) used by the planet. This may only be assigned to during the <code>shipWillExitWitchspace</code> and <code>shipWillLaunchFromStation</code> events.
 
The name of the texture file (diffuse map) used by the planet. This may only be assigned to during the <code>shipWillExitWitchspace</code> and <code>shipWillLaunchFromStation</code> events.
 +
 +
=== <code>terminatorThresholdVector</code> ===
 +
{{oolite-prop-added|1.89}}
 +
'''terminatorThresholdVector''' : [[Oolite JavaScript Reference: Vector|Vector]] (read/write)
 +
 +
This property gives control over the color of the planet's terminator. The way the property works is not entirely straightforward, so see [https://bb.oolite.space/viewtopic.php?p=271058#p271058 this post on BB] for more information.
  
 
== Non-standard Properties ==
 
== Non-standard Properties ==
Line 42: Line 79:
 
=== <code>isGasGiant</code> ===
 
=== <code>isGasGiant</code> ===
 
  '''isGasGiant''' : Boolean (read/write)
 
  '''isGasGiant''' : Boolean (read/write)
<code>true</code> if the entity is a gas giant, <code>false</code> otherwise.  Created and used by the [[System Redux 2 OXP]].
+
<code>true</code> if the entity is a gas giant, <code>false</code> otherwise.  Created and used by the [[System_Redux_(Oolite) | System Redux OXP]].
  
  
 
[[Category:Oolite JavaScript Reference]]
 
[[Category:Oolite JavaScript Reference]]

Latest revision as of 02:19, 29 February 2024

Prototype: Entity
Subtypes: none

The Planet class is an Entity representing a planet or moon. A Planet has all the properties and methods of a Entity, and several others.

Properties

airColor

This property was added in Oolite test release 1.89.

airColor : Array (read/write)

The colour of the planets atmosphere. An array of RGBA components, but can be set with any other colour specifier.

airColorMixRatio

This property was added in Oolite test release 1.89.

airColorMixRatio : Number (read/write)

The amount of air colour that be mixed in the overall atmosphere color. A number from 0.0 to 1.0.

airDensity

This property was added in Oolite test release 1.91.

airDensity : Number (read/write)

The density of the planet's atmosphere. A number from 0.0 to 1.0.

hasAtmosphere

hasAtmosphere : Boolean (read-only)

true if the entity has an atmosphere, false otherwise. Planets created with the System.addMoon() method (or corresponding legacy scripting method) have no atmosphere, other planets do.

illuminationColor

This property was added in Oolite test release 1.91.

illuminationColor : Array (read/write)

The colour of the planet's illumination such as cities light. An array of RGBA components, but can be set with any other colour specifier.

Note: Illumination is inserted as a grayscale map in the alpha channel of the planet's diffuse texture. If no illumination map is defined, then you can still access this property but you will not see any difference by changing it - without an illumination map the dark side of the planet remains dark in all cases.

isMainPlanet

isMainPlanet : Boolean (read-only)

true if the entity is the main planet of the current system, false otherwise.

See also: system.mainPlanet

name

This property was added in Oolite test release 1.79.

name : String (read/write)

The name of the planet, as set by the planet_name property in planetinfo.plist

For convenience of working with secondary planets, this can be written to by JS. For the system main planet, writing to system.info.planet_name is preferred.

radius

radius : Number (read-only)

The equatorial radius of the planet, in metres.

For reference: radii of main planets generated by Oolite vary between 28160 and 69110 meters. This value is shown on the planet information screen as: 2816 km to 6911 km. (Note the discrepancy of a factor 100.)

rotationalVelocity

rotationalVelocity : Number (read/write)

The rotation speed of a planet. A value of x means: x/Math.PI rotations per second. The main planet default value is pseudorandom and varies between 0.0 until 0.01

texture

texture : String (read/write)

The name of the texture file (diffuse map) used by the planet. This may only be assigned to during the shipWillExitWitchspace and shipWillLaunchFromStation events.

terminatorThresholdVector

This property was added in Oolite test release 1.89.

terminatorThresholdVector : Vector (read/write)

This property gives control over the color of the planet's terminator. The way the property works is not entirely straightforward, so see this post on BB for more information.

Non-standard Properties

These are not part of the official object model, but are used in various OXPs by the authors to allow manipulation of the OXP by other scripts and expansions. Important: the use of custom properties without a unique OXP-specific prefix is strongly discouraged and may cause conflicts with future versions of Oolite.

solarGasGiant

solarGasGiant : Boolean (read/write)

true if the entity is a gas giant and should therefore prevent attempts to land on the planet's surface, false otherwise. Created for the Solar System OXP and used by the Planetfall OXP.

PFNoLand and PFNoLandQuiet

PFNoLand : Boolean (read/write)
PFNoLandQuiet : Boolean (read/write)

true if landing will be prevented on the planet's surface (with and without a warning message), false otherwise. Created and used by the Planetfall OXP from version 1.40 onwards.

isGasGiant

isGasGiant : Boolean (read/write)

true if the entity is a gas giant, false otherwise. Created and used by the System Redux OXP.