Difference between revisions of "Oolite JavaScript Reference: Planet"

From Elite Wiki
m (Moving Oolite JS reference into a *correctly-named* subcategory of Oolite scripting.)
(Updated for 1.74.)
Line 1: Line 1:
 
<small>'''Prototype:''' <code>[[Oolite/Development/Scripting/Class/Entity|Entity]]</code></small><br />
 
<small>'''Prototype:''' <code>[[Oolite/Development/Scripting/Class/Entity|Entity]]</code></small><br />
 
<small>'''Subtypes:''' none
 
<small>'''Subtypes:''' none
 
{{Oolite-class-added|1.70}}
 
   
 
The '''<code>Planet</code>''' class is an <code>[[Oolite/Development/Scripting/Class/Entity|Entity]]</code> representing a planet or moon. A <code>Planet</code> has all the properties and methods of a <code>Entity</code>, and several others.
 
The '''<code>Planet</code>''' class is an <code>[[Oolite/Development/Scripting/Class/Entity|Entity]]</code> representing a planet or moon. A <code>Planet</code> has all the properties and methods of a <code>Entity</code>, and several others.
   
 
== Properties ==
 
== Properties ==
=== isMainPlanet ===
 
'''isMainPlanet''' : Boolean (read-only)
 
<code>true</code> if the entity is the main planet of the current system, <code>false</code> otherwise.
 
 
 
=== hasAtmosphere ===
 
=== hasAtmosphere ===
 
'''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.
  +
  +
=== isMainPlanet ===
  +
'''isMainPlanet''' : Boolean (read-only)
  +
<code>true</code> if the entity is the main planet of the current system, <code>false</code> otherwise.
   
 
=== radius ===
 
=== radius ===
 
'''radius''' : Number (read-only)
 
'''radius''' : Number (read-only)
The equatorial radius of the planet, in metres.<br>
+
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 F7 screen as: 2816 km to 6911 km. (note the discrepancy of a factor 100)
+
  +
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.)
  +
  +
=== <code>texture</code> ===
  +
'''texture''' : String (read/write)
  +
  +
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.
  +
  +
== 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.''
   
== Extended 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.''
 
 
=== solarGasGiant ===
 
=== solarGasGiant ===
 
'''solarGasGiant''' : Boolean (read/write)
 
'''solarGasGiant''' : Boolean (read/write)
 
<code>true</code> if the entity is a gas giant and should therefore prevent attempts to land on the planet's surface, <code>false</code> otherwise. Created and used by the [[Planetfall OXP]].
 
<code>true</code> if the entity is a gas giant and should therefore prevent attempts to land on the planet's surface, <code>false</code> otherwise. Created and used by the [[Planetfall OXP]].
  +
 
=== isGasGiant ===
 
=== isGasGiant ===
 
'''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 2 OXP]].
   
== Methods ==
 
 
=== <code>setTexture</code> ===
 
function '''setTexture'''(texture: String)
 
{{Oolite-method-added|1.71}}
 
 
Uses the texture file (must be a .png) as texture for the planet. This function only works when called during the shipWillExitWitchspace and shipWillLaunchFromStation events.
 
   
 
[[Category:Oolite JavaScript Reference]]
 
[[Category:Oolite JavaScript Reference]]

Revision as of 14:47, 20 June 2010

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

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.

isMainPlanet

isMainPlanet : Boolean (read-only)

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

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.)

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.

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 and used by the Planetfall OXP.

isGasGiant

isGasGiant : Boolean (read/write)

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