Page 1 of 1

Javascript: Versioning worldscripts

Posted: Wed Nov 16, 2016 7:16 am
by alaric of rothestes
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.

Re: Javascript: Versioning worldscripts

Posted: Thu Nov 17, 2016 8:51 pm
by cim
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)