It's not continuing to fire every 5 seconds, it's just firing one last time? That's just because you've got the sequence inside this.$checkDistance in the wrong order? I dunno.
Delete the timer just above the "//spring the trap" comment. I dunno.
The exception is caused because you aren't deleting it.
if (this.distanceChecker) {
this.distanceChecker.stop();
delete this.distanceChecker;
}
That will still cause a different exception, if it's called one last time? I dunno.
'use strict';
Needs to be at the top of file before anything else.
"There are large, white swans, and there are small, black swans," he explained, "But there are no medium-sized swans, and there are no grey swans. The non-existence of grey swans mitigates against belief in Mr Darwin's theory."
Is it apparently working, and just causing these exceptions afterwards? Or are you not saying that it's not actually working at all?
"There are large, white swans, and there are small, black swans," he explained, "But there are no medium-sized swans, and there are no grey swans. The non-existence of grey swans mitigates against belief in Mr Darwin's theory."
Not sure if this is the issue, but you're calling $populateWithTrap from the systemWillPopulate routine as well as the shipWillLaunchFromStation routine. I think you only need one of these calls. Also, I don't think systemWillPopulate takes station as a parameter.
Not sure if this is the issue, but you're calling $populateWithTrap from the systemWillPopulate routine as well as the shipWillLaunchFromStation routine. I think you only need one of these calls. Also, I don't think systemWillPopulate takes station as a parameter.
That's the issue - you're starting two timers (at least two, depending on how many times you launch from the station before trying to stop one), and only stopping one of them. The other you're deleting the timer object that it uses to determine what to do, but not stopping the internal routine used to call it on a timer.
What I'd recommend is that rather than using shipWillLaunchFromStation as your debug function, you get the debug console and enter
You'll also want a shipWillEnterWitchspace function which checks if the timer exists and is running, and stops it if so, or it'll keep running when you enter a new system (and you may get a second one)