Scripters cove

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2921
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Scripters cove

Post by Wildeblood »

phkb wrote: Sun Feb 15, 2026 9:17 pm
Wildeblood wrote: Sun Feb 15, 2026 5:31 pm
...on for 1/2 second then off for one second. I can do this with one timer, but it involves some kind of modulo arithmetic or somethin'?
I would have though just a boolean switch would have been sufficient: if the timer is on a 0.5 second repeat, flipping the boolean value would allow you to switch the effect on and off.
Yeah, anyway :mrgreen: Moving right along...

Could I please get a definitive answer to the (mysterious to me) question of if, and when, one needs to clean up timers in world-scripts?

this.shipDied = this.reset = this.someoneLookedAtMeFunny = function () { /* code to stop and delete timers */ }

Using shipDied() should be sufficient for ship-scripts(?), but in world-scripts this seems to have been subject to changing fashions over the years.

Addendum: it says here (https://wiki.alioth.net/index.php/Oolit ... onstructor), "You should use entityDestroyed in ship scripts to clean up timers." But, it makes no mention of world-scripts.
R.I.P. John Lodge, 1943-2025.
Post Reply