Javascript: Versioning worldscripts

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

Post Reply
alaric of rothestes
Average
Average
Posts: 15
Joined: Thu Oct 27, 2016 7:38 pm

Javascript: Versioning worldscripts

Post by alaric of rothestes » Wed Nov 16, 2016 7:16 am

Hi dev team,

From the information on the Wiki: if multiple world scripts of the same name are loaded one is arbitrary chosen and the rest are discarded. Also, this.version is copied from manifest.plist in 1.79+

This seems a bit silly to me. I have many "common" functions in my OXPs which I am keeping in a single script. If I make a "my-oxp-utilities" script which one OXP uses, then release another OXP with an extended (but backwards compatible) version of "my-oxp-utilities", I would have no choice but to give it a new name, since I can't be sure Oolite will use the more recent version instead of the older one.

Surely it makes more sense to merge the duplicate copies based upon a higher version number? The onus, of course, being on the author to ensure backwards compatibility with previous versions. To make life even easier, you could perhaps use a new property. Ie: this.internalVersion or this.revision, which must be a Number or else it is assigned Number.MIN_VALUE. It would at least give us some more compile-time code reuse :)

alaric.

User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4018
Joined: Fri Nov 11, 2011 6:19 pm

Re: Javascript: Versioning worldscripts

Post by cim » Thu Nov 17, 2016 8:51 pm

The "choose one and discard" is...
1) A warning, to all developers, to remember to namespace their scripts
2) A way to allow OXP developers to override core game world scripts

If you have a script to share between OXPs, then package that script up as an OXP in its own right, and make the other OXPs depend on it. Then you only need one copy of that script at all, and both OXPs (if installed) can use it, as can other OXP developers. You can even set versioned dependencies, if one OXP requires a specific version but the other is less picky.

(See OXPs such as Library, Cabal Common Library, Ship Storage Helper)

Post Reply