Using IDs has been deprecated: ID numbers stop referring to valid entities the moment the player jumps from one system to another, and are recycled as needed by the entities inside the new system. Trying to keep track of ships using IDs would quickly cause way too many headaches. If you need to keep track of a ship, or any entity exposed to js, you can assign the entity directly to a holder variable (which will work as using a pointer in c, if you know what I mean: no extra memory usage, and immediate access to all its properties).
We did have a universalID getter in js, but - following its deprecation for scripting purposes - it was removed in rev3520 (almost 2 years ago). If you want to assign IDs to ships for your own reasons, you can always add dynamic properties to an entity, as with all js objects:
Code: Select all
thatShip= system.addShips('thatship',1)
thatShip.specialID=223244;
<snip>
if (thatShip.specialID && thatShip.specialID === 223244){
// do something here...
}
I've got to admit I've never even thought of 2 buttons per oxp script, but I think I know what you mean - I've seen games with a primary mode button & a secondary mode one. It's a bit of a slippery slope too, because then it'll be just a matter of time before someone needs a tertiary mode button...
However, you can record when the equipment was activated and enable different actions for 'single click' and 'double click'. This might help:
Code: Select all
this.lastClick = 0;
this.firstModeDelay = .01; // 10 milliseconds
this.activated = function () {
var useFirstMode = clock.absoluteSeconds-this.lastClick > this.firstModeDelay;
this.lastClick = clock.absoluteSeconds;
if (useFirstMode) {
this.modeTimer = new timer(this, this.firstMode, .25);
} else {
if (this.modeTimer && this.modeTimer.isRunning) this.modeTimer.stop();
this.secondMode();
}
}
this.firstMode = function () {
// do something
}
this.secondMode = function () {
// do something else
}
Assuming I've coded it right, if you press the activate equipment key once it will 'fire' after .25 seconds ( a limitation of timers) or, if you press it twice within 10 milliseconds it'll do whatever is inside .secondMode immediately.
This bit of code has got 'a few' problems, but it's just meant as a starting point...
For example, the .25 seconds thing is a limitation of timers: if you use frame callbacks you can get around this 250 milliseconds limitation, but the code does become a bit more complex...