I was already sceptical when you proposed it as I never could make this type of stuff working. By calling the worldScript from within the ship script, Oolite still sees the ship script as the active script. Today I finally had the chance to test it with a nighty (r5144). I rewrote Lovecats, with above code, but without success. The systems stay marked. I expect a lot of oxps will not be able to unmark systems in the future.cim wrote:Lovecats unmarks two at once a few times. Though it does that from a ship script so would need adjusting anyway.
On the other hand, Feudal States already expects it to be working in the way thatsetInstructions
does, with the option to take an array to set more than one system at once. It works, too, because of how type conversion works in the JS libraries.
The parameter is only a convenience, of course, so if the code is to be rewritten anyway:I'd rather not change the meaning of markSystem to break any more code than the unavoidable ship script case.Code: Select all
// in world script this._unmarkSystem = function(id) { mission.unmarkSystem(id); } // in ship script this.shipDied = function() { worldScripts.foo._unmarkSystem(system.ID); }
mission.markSystemAs(id,script)
is a possibility.
In the past I had similar problems and the only solution I could come up with was starting a timer with zero seconds delay in the worldscript. When that timer fires, it does it from the worldscript and the active script is than indeed the intended one. I think that procedure will also be needed in future to unmark the destinations from ship scripts.