Difference between revisions of "Legacy Scripting"

From Elite Wiki
(Links: Added another)
(Added Ahruman's note on String Variables (not that I understand any of it!))
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[File:Plist-XML-ASCII-ill.png|thumb|right|702px|XML (left) & OpenStep (right)]]
 
[[File:Plist-XML-ASCII-ill.png|thumb|right|702px|XML (left) & OpenStep (right)]]
Older OXPs (from [[User:Aegidian|Aegidian]]'s day) were written in Legacy Script. So if you look, for example, at the innards of [[Benulobiweed Inc.|Charlie's Benulobiweed oxp's]] from 2006-7 they are all written in the legacy scripts. When Aegidian started writing Oolite it was purely for the AppleMac, hence the ability to overwrite portions of the vanilla game code in OpenStep (the Windows and Linux ports were written later by [[David Taylor]] & [[Dylan Smith]]). XML was also included as a valid OXP language.
+
Older OXPs (from [[User:Aegidian|Aegidian]]'s day) were written ''entirely'' in Legacy Script. So if you look, for example, at the innards of [[Benulobiweed Inc.|Charlie's Benulobiweed oxp's]] from 2006-7 you will find that everything is written in the legacy scripts. When Aegidian started writing Oolite it was purely for the AppleMac, hence the ability to overwrite portions of the vanilla game code in OpenStep (the Windows and Linux ports were written later by [[David Taylor]] & [[Dylan Smith]]). XML was also included as a valid OXP language.
 +
 
 +
'''Nowadays Legacy scripting is still used in [[Property list]] or .plist files.'''
  
 
'''Legacy script thus comes in two versions: XML & OpenStep.'''
 
'''Legacy script thus comes in two versions: XML & OpenStep.'''
Line 6: Line 8:
 
*See [[Methods]] for more technical information on legacy scripting
 
*See [[Methods]] for more technical information on legacy scripting
  
*Commander Jettison wrote 2 small programmes for translating the more opaque XML into OpenStep which you can find [http://aegidian.org/bb/viewtopic.php?f=2&t=10039 here] (2011-17). The older version is on the first page, the newer on the third page of the thread.
+
*'''Converters''': Commander Jettison wrote 2 small programmes for translating the more opaque XML into OpenStep which you can find [http://aegidian.org/bb/viewtopic.php?f=2&t=10039 here] (2011-17). The older version is on the first page, the newer on the third page of the thread.
  
*The commodities coding in the older OXPs is particularly obscure. See [[Commodity Calculator]] for a helpful download for interpreting it.
+
*'''Commodities''': The commodities coding in the older OXPs is particularly obscure. See [[Commodity Calculator]] for a helpful download for interpreting it.
 +
 
 +
*'''String Variables''': Legacy scripting mechanism only supports string variables (although they can do arithmetic on strings containing numerical values). For JavaScript, mission variables with a purely numeric values are converted to numbers when retrieved, and setting a mission variable to a number converts it to a string behind the scenes; in other words, mission variables can be numbers or strings in the JavaScript programming interface but are always strings internally and in saved games. [http://oolite.aegidian.org/bb/viewtopic.php?p=97266#p97266 JensAyton (2010)].
  
 
== Javascript ==
 
== Javascript ==
Line 32: Line 36:
 
*[[TwostateXML]]
 
*[[TwostateXML]]
  
 +
*[https://aegidian.org/bb/viewtopic.php?f=4&t=18284 The bare minimum for a game-recognizable ship OXP using OpenStep] (2016)
 +
*[http://aegidian.org/bb/viewtopic.php?p=171074#p171074 Adding suns, moons & ships to system using legacy script] (2007)
 
*[http://www.aegidian.org/bb/viewtopic.php?f=6&t=2784 Anyone want to write scripts using JavaScript?] (2007): [[David Taylor]]/DAJT's first introduction of SpiderMonkey into Oolite.
 
*[http://www.aegidian.org/bb/viewtopic.php?f=6&t=2784 Anyone want to write scripts using JavaScript?] (2007): [[David Taylor]]/DAJT's first introduction of SpiderMonkey into Oolite.
 +
  
 
If you need more information, you can navigate to a relevant page and then inspect the original 2006 version (if there was one) by clicking on the ''history'' tab at the top of the page and comparing the early version with the current one. Ahruman started introducing Javascript after he took over from Aegidian which was in early/mid 2007. Since then, the relevant pages have been edited, replacing the legacy script with the newer Javascript. ''History'' restores the originals. Note that in a few cases (eg: Commodities.plist) the original legacy script no longer works.
 
If you need more information, you can navigate to a relevant page and then inspect the original 2006 version (if there was one) by clicking on the ''history'' tab at the top of the page and comparing the early version with the current one. Ahruman started introducing Javascript after he took over from Aegidian which was in early/mid 2007. Since then, the relevant pages have been edited, replacing the legacy script with the newer Javascript. ''History'' restores the originals. Note that in a few cases (eg: Commodities.plist) the original legacy script no longer works.

Revision as of 08:19, 29 September 2022

XML (left) & OpenStep (right)

Older OXPs (from Aegidian's day) were written entirely in Legacy Script. So if you look, for example, at the innards of Charlie's Benulobiweed oxp's from 2006-7 you will find that everything is written in the legacy scripts. When Aegidian started writing Oolite it was purely for the AppleMac, hence the ability to overwrite portions of the vanilla game code in OpenStep (the Windows and Linux ports were written later by David Taylor & Dylan Smith). XML was also included as a valid OXP language.

Nowadays Legacy scripting is still used in Property list or .plist files.

Legacy script thus comes in two versions: XML & OpenStep.

  • See Methods for more technical information on legacy scripting
  • Converters: Commander Jettison wrote 2 small programmes for translating the more opaque XML into OpenStep which you can find here (2011-17). The older version is on the first page, the newer on the third page of the thread.
  • Commodities: The commodities coding in the older OXPs is particularly obscure. See Commodity Calculator for a helpful download for interpreting it.
  • String Variables: Legacy scripting mechanism only supports string variables (although they can do arithmetic on strings containing numerical values). For JavaScript, mission variables with a purely numeric values are converted to numbers when retrieved, and setting a mission variable to a number converts it to a string behind the scenes; in other words, mission variables can be numbers or strings in the JavaScript programming interface but are always strings internally and in saved games. JensAyton (2010).

Javascript

Ahruman (2006-13) started introducing Javascript for OXPs when he took over from Aegidian as Lead Designer. But it took 4 years to create a stable new game with Javascript, shaders and his other modernizations. Cim (2013-15) then started changing some of the coding - for example for commodities & AI's.

Modern OXPs are written in JavaScript. Specifically oolite.jsVersion 185, an Oolite specific variant of ECMAv5. It is the same Spidermonkey version (1.8.5 - March 2011) that Firefox 4 shipped with many years ago, but it is a special build for Oolite. This is the version that we have almost always had and it has not changed between versions of the game since Ahruman's day. It is unlikely to change in the future (due to the immense amount of work involved in tampering with it!).

  • See OXP howto for an introduction to current scripting with Javascript

Updating old OXPs

Rather than delve into the intricacies of legacy scripting, it might be easier to write an over-ride OXP in javascript. See Sothis & SothisTC for an example. KillerWolf wrote Sothis in a mix of XML legacy script & javascript in 2010. Spara wrote a javascript override (improving the markets) which is currently (May 2021) being updated (reintroducing dockability etc, which were all lost as Oolite changed).

Links


If you need more information, you can navigate to a relevant page and then inspect the original 2006 version (if there was one) by clicking on the history tab at the top of the page and comparing the early version with the current one. Ahruman started introducing Javascript after he took over from Aegidian which was in early/mid 2007. Since then, the relevant pages have been edited, replacing the legacy script with the newer Javascript. History restores the originals. Note that in a few cases (eg: Commodities.plist) the original legacy script no longer works.