With Oolite 1.75 there is the new frame callback available, allowing for some nice possibilities in animation.
I've been playing with this a little, and to aid my own understanding I've put together a small demo OXP (with the assistance of Ahruman and Eric Walch). It is available here.
Once installed, to activate it just launch from the main station (any system) and within 10 seconds target the nav buoy. Two test drones should be spawned, one on either side of the buoy. One uses the callback, and the other the old javascript timer way of doing animation as a comparison.
Aside from that it doesn't do anything but give an example to OXP makers - for me there are many interesting possibilities for new ships and features. Oh and be warned, watching the drones gets hypnotic after a while
As the first line above may suggest - requires Oolite 1.75 or higher to run.
Flying_Dutchman.oxp in version 1.6 contains an example for frame callback as well. I found it very useful for raising the ship temperature. The example actually combines frame callbacks and a standard timer, because I needed the timer to check if a certain temperature treshold has been reached.
To show that they are custom properties, not built-in ones (to make it clear and remove the chance of namespace pollution) - it was one of Ahruman's requests.
With regard to jumping out, I will update the OXP for that. I must admit this is the one part of the frame callback I'm not fully convinced of yet, as I can see one or two other scenarios where problems may occur.
An updated version including the callback removal on player jumping is now uploaded.
To show that they are custom properties, not built-in ones (to make it clear and remove the chance of namespace pollution) - it was one of Ahruman's requests.
Ah! So that is something we all should generally do?
As I'm in the process of OXP-updating that's something I could implement now—at least for the OXPs I still have to update in the current roll call.
Ah! So that is something we all should generally do?
Yes. (The built-in scripts actually use underscores instead, but Kaks pointed out that dollar signs are more idiomatic in JavaScript. Either is fine by me, but note that there are a few special properties identified by double underscores used by SpiderMonkey and Oolite.)