I inferred from the documentation that this is possible, but on grepping my entire AddOns directory I can only see examples of its use from within the same OXP. Can anyone put me straight on this? I was under the impression that the system object is shared, and all OXPs should see the same view . . . . ? TIA,
Check if the ship is/ships are there by creating a dump (pause and press 0) and check the log. If it's not there check the roles and the values of count, position and radius.
Check if the ship is/ships are there by creating a dump (pause and press 0) and check the log. If it's not there check the roles and the values of count, position and radius.
Sorry if I wasn't clear, I'm know the ships are there, someone else has already created them - it's the
I inferred from the documentation that this is possible, but on grepping my entire AddOns directory I can only see examples of its use from within the same OXP. Can anyone put me straight on this? I was under the impression that the system object is shared, and all OXPs should see the same view . . . . ?
Correct.
I’m with Svengali on this one; the most likely explanations are that you’re calling shipsWithRole() before the other OXP has actually added anything, or that you’re misspelling the role. That the function works can easily be verified by typing system.shipsWithRole("trader") in the debug console.
I’m with Svengali on this one; the most likely explanations are that you’re calling shipsWithRole() before the other OXP has actually added anything, or that you’re misspelling the role. That the function works can easily be verified by typing system.shipsWithRole("trader") in the debug console.
I concur that the order of execution may be significant, not sure what I can do about this, I'm currently using shipExitedWitchspace to allow for other OXPs to do their stuff first in eg. shipWillExitWitchspace . . . not brilliant - is there a better way? I'm not misspelling the role (unless I'm misspelling twice with roles from 2 different OXPs, but I am cut&pasting) so it looks like I need to make my code a bit cleverer, or just loop & wait (?!)
Is there any existing code I can refer to? Otherwise, it's back to the drawing board . . . Thanks, Ian.
I'm currently using shipExitedWitchspace to allow for other OXPs to do their stuff first in eg. shipWillExitWitchspace . . . not brilliant - is there a better way?
Is there any existing code I can refer to? Otherwise, it's back to the drawing board . . . Thanks, Ian.
The easiest way is using a timer, like in rockHermitLocator.oxp:
this.shipExitedWitchspace = function ()
{
// use a delay to allow all other oxp's to add their stuff before we start counting hermits.
this.buoyTimer = new Timer(this, this.addBuoys, 0.90);
}
Than in this.addBuoys() the code is executed. For the timer is any value > 0 good enough. During the handler is the clock halted and starts ticking again after all oxps have executed their this.shipExitedWitchspace() code. So, when the timer starts the function, the ships you are looking for are added by that other oxp, no matter in which order they executed.
this.shipExitedWitchspace = function ()
{
// use a delay to allow all other oxp's to add their stuff before we start counting hermits.
this.buoyTimer = new Timer(this, this.addBuoys, 0.90);
}
I notice the function takes no parameters; my function will need to, is this supported, or will I need to use "this" to pass them?
A fairly simple example to review is the Cargo Shepherd I just released.
That scans for cargopods (by role and scanclass) and if it finds them it acts on them. And it's a very simple and small script. Have a look at that and see if it helps you.