What is the difference between the ship script event handlers shipWillEnterWitchspace and playerWillEnterWitchspace?
I was under the impression that shipWillEnterWitchspace would trigger when the NPC itself jumps out, while playerWillEnterWitchspace would trigger when the player jumps out. Apparently I am mistaken, at least for current trunk. I think it was working this way a few versions back, or at least I always assumed that this was the case.
Or has shipWillEnterWitchspace been deprecated?
What I expected shipWillEnterWitchspace would do, is actually done by shipWillEnterWormhole. (I just noticed that a personality still broadcast messages after jumping out. Only this way I found out that the broadcast timer isn't removed on shipWillEnterWitchspace. I haven't witnessed that before, but it also may be that I just didn't hang around after a personality jumped out.)
shipWillEnterWitchspace() is sent to world scripts/player ship script and tells you the context of the jump. playerWillEnterWitchspace() is sent to NPC ships, later in the process (about as late as possible).
It has never been there in the first place. It has always been a player-only thing. The two wiki handler pages used to be one. Kaks has split them in two separate pages a year ago. But some handlers stayed in both pages. I thought I deleted some of there bugs, but apparently not all. shipWillEnterWitchspace will only be send to worldScripts and has never been send to ship scripts.
It has never been there in the first place. It has always been a player-only thing.
Thanks for the clarification. Apparently I always only assumed/imagined that it was working the way I wanted to. Will have to hunt for wrong use in other ship scripts as well.
Hmm, unfortunately I didn't manage as clean a cut between the ship & world events - on the wiki - as I would have liked.
As why there are 2 js events for just one Oolite event, one with & one without parameters, it's indeed a mystery - an API bug if you will. I'd deprecate the slightly confusing shipWillEnterWitchspace, and use playerWillEnterWitchspace, making sure it sends the context of the jump.
As why there are 2 js events for just one Oolite event, one with & one without parameters, it's indeed a mystery - an API bug if you will. I'd deprecate the slightly confusing shipWillEnterWitchspace, and use playerWillEnterWitchspace, making sure it sends the context of the jump.
Too late! (Actually, the Right Thing here would be to rename NPC shipWillEnterWormhole to shipWillEnterWitchspace for consistency, but I ain’t doing that now either. The scripting interface is frozen, not mildly chilled.)