Difference between revisions of "Oolite JavaScript Reference: Oolite"

From Elite Wiki
m (compareVersion: corrected old casing of Log() -> log())
(Updated for 1.74.)
Line 1: Line 1:
 
<small>'''Prototype:''' <code>Object</code></small><br />
 
<small>'''Prototype:''' <code>Object</code></small><br />
 
<small>'''Subtypes:''' none
 
<small>'''Subtypes:''' none
 
{{Oolite-class-added|1.70}}
 
  
 
The '''<code>Oolite</code>''' class represents Oolite itself. It allows scripts to access information about the application. There is a global instance of <code>Oolite</code>, named <code>oolite</code>.
 
The '''<code>Oolite</code>''' class represents Oolite itself. It allows scripts to access information about the application. There is a global instance of <code>Oolite</code>, named <code>oolite</code>.
Line 8: Line 6:
 
== Properties ==
 
== Properties ==
 
=== <code>gameSettings</code> ===
 
=== <code>gameSettings</code> ===
{{Oolite-class-added|1.74}}
+
{{Oolite-prop-added|1.74}}
 
  '''gameSettings''' : Object(read-only)
 
  '''gameSettings''' : Object(read-only)
 
This property allows an OXP to detect various game settings. It has the following read-only properties:
 
This property allows an OXP to detect various game settings. It has the following read-only properties:
  
  autosave : Boolean (true, false)
+
  autosave : Boolean
  gameWindow : Object ( see below )
+
  gameWindow : Object (see below)
  musicMode : String (either 'MUSIC_OFF', 'MUSIC_ON', or 'MUSIC_ITUNES')
+
  musicMode : String ("MUSIC_OFF", "MUSIC_ON", or "MUSIC_ITUNES")
  procedurallyTexturedPlanets : Boolean (true, false)
+
  procedurallyTexturedPlanets : Boolean
  reducedDetailGraphics : Boolean (true, false)
+
  reducedDetailGraphics : Boolean
  shaderEffectsLevel : String (either 'SHADERS_OFF', 'SHADERS_SIMPLE', 'SHADERS_FULL', or 'SHADERS_NOT_SUPPORTED')
+
  shaderEffectsLevel : String ("SHADERS_OFF", "SHADERS_SIMPLE", "SHADERS_FULL", or "SHADERS_NOT_SUPPORTED")
  speechOn : Boolean (true, false)
+
  speechOn : Boolean
  wireframeGraphics : Boolean (true, false)
+
  wireframeGraphics : Boolean
 
 
the gameWindow property contains the following
 
height
 
width
 
fullScreen
 
 
 
These proposed properties are not finalised yet, and might be different when 1.74 is released.
 
  
 +
the gameWindow property contains the following properties:
 +
height : Number
 +
width : Number
 +
fullScreen : Boolean
  
 
=== <code>jsVersion</code> ===
 
=== <code>jsVersion</code> ===
 
  '''jsVersion''' : Number (read-only)
 
  '''jsVersion''' : Number (read-only)
The version of the JavaScript language implemented by this version of Oolite, multiplied by 100, as an integer. For instance, for [http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7 JavaScript 1.7] (used in Oolite 1.70), this will be equal to <code>170</code>.
+
The version of the JavaScript language implemented by this version of Oolite, multiplied by 100, as an integer. For instance, for [http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7 JavaScript 1.7] (used in Oolite 1.74), this will be equal to <code>170</code>.
  
 
=== <code>jsVersionString</code> ===
 
=== <code>jsVersionString</code> ===
Line 39: Line 34:
 
=== <code>version</code> ===
 
=== <code>version</code> ===
 
  '''version''' : Array (read-only)
 
  '''version''' : Array (read-only)
The version of Oolite, as an array of version components. For instance, for Oolite 1.70 this will be equal to <code>[1, 70]</code>. For a hypothetical version 1.70.1, it will be equal to <code>[1, 70, 1]</code>.
+
The version of Oolite, as an array of version components. For instance, for Oolite 1.74 this is <code>[1, 74]</code>. For version 1.73.4, it is <code>[1, 73, 4]</code>.
  
 
=== <code>versionString</code> ===
 
=== <code>versionString</code> ===
 
  '''versionString''' : String (read-only)
 
  '''versionString''' : String (read-only)
The version of Oolite, as a string. For instance, for Oolite 1.70 this will be equal to <code>"1.70"</code>. For a hypothetical version 1.70.1, it will be equal to <code>"1.70.1"</code>.
+
The version of Oolite, as a string. For instance, for Oolite 1.74 this is <code>"1.74"</code>. For version 1.73.4, it is <code>"1.73.4"</code>.
  
  

Revision as of 12:03, 18 June 2010

Prototype: Object
Subtypes: none

The Oolite class represents Oolite itself. It allows scripts to access information about the application. There is a global instance of Oolite, named oolite.

Properties

gameSettings

This property was added in Oolite test release 1.74.

gameSettings : Object(read-only)

This property allows an OXP to detect various game settings. It has the following read-only properties:

autosave : Boolean
gameWindow : Object (see below)
musicMode : String ("MUSIC_OFF", "MUSIC_ON", or "MUSIC_ITUNES")
procedurallyTexturedPlanets : Boolean
reducedDetailGraphics : Boolean
shaderEffectsLevel : String ("SHADERS_OFF", "SHADERS_SIMPLE", "SHADERS_FULL", or "SHADERS_NOT_SUPPORTED")
speechOn : Boolean
wireframeGraphics : Boolean

the gameWindow property contains the following properties:

height : Number
width : Number
fullScreen : Boolean

jsVersion

jsVersion : Number (read-only)

The version of the JavaScript language implemented by this version of Oolite, multiplied by 100, as an integer. For instance, for JavaScript 1.7 (used in Oolite 1.74), this will be equal to 170.

jsVersionString

jsVersionString : String (read-only)

The version of the JavaScript language implemented by this version of Oolite, as a string. For instance, for JavaScript 1.7, this will be equal to "1.7".

version

version : Array (read-only)

The version of Oolite, as an array of version components. For instance, for Oolite 1.74 this is [1, 74]. For version 1.73.4, it is [1, 73, 4].

versionString

versionString : String (read-only)

The version of Oolite, as a string. For instance, for Oolite 1.74 this is "1.74". For version 1.73.4, it is "1.73.4".


Methods

compareVersion

function compareVersion(versionSpec) : Number

Compare the version of Oolite to versionSpec, which may be either a string or an array (in the format given by version). If the current version of Oolite is less than versionSpec, 1 is returned. If the current version of Oolite is greater than versionSpec, -1 is returned. If they are equal, 0 is returned. Example:

if (0 < oolite.compareVersion("1.80"))
{
    // Oolite version is older than 1.80.
    log(this.name, "An old version of Oolite (" + oolite.versionString + ") is in use. Some features of SuperDuperOXP will not be available.")
}
else
{
    // Enable advanced features here.
}