Page 1 of 1

Catch nuke explosion event

Posted: Sun Sep 18, 2022 1:42 am
by starholme
I want to run code to modify the terrain wherever it gets nuked. I couldn't see any particular event that would be triggered on a nuke explosion. Currently I'm searching over the surface for 'nuclear-ground' tiles. This of course isn't particularly efficient on large maps.

Can you suggest a better way to get the location of a nuke explosion?

Re: Catch nuke explosion event

Posted: Sun Sep 18, 2022 1:53 am
by FuryoftheStars

Re: Catch nuke explosion event

Posted: Sun Sep 18, 2022 4:07 am
by starholme
Wow, that is way better than what I'd planned. Thank you for the link. I'll just use that mod, but I still want to dig in and see 'how' they did it!

Re: Catch nuke explosion event

Posted: Sun Sep 18, 2022 11:57 am
by Deadlock989
starholme wrote: Sun Sep 18, 2022 1:42 am Can you suggest a better way to get the location of a nuke explosion?
You can add a scripted trigger effect to the action delivery of the nuke, which you listen for in the on_script_trigger_effect event, checking against the id of your scripted effect.

Re: Catch nuke explosion event

Posted: Sun Sep 18, 2022 3:39 pm
by BicycleEater
Yeah, the mod works pretty much entirely with script triggers, which are caught on line 340-416 here:
https://github.com/More-Wrong/Factorio- ... ontrol.lua
and are generated from here:
https://github.com/More-Wrong/Factorio- ... osions.lua
each entry specifying an array of TriggerEffects:
https://wiki.factorio.com/Types/TriggerEffect
and the actual scripting done from the

Code: Select all

type="script"
entries.
I generate the TriggerEffects and use them in different weapons, and that is all pretty indirect now - it's much clearer how it works in the pre-0.3.x updates, so try looking at the 0.2.13 update, with the github commit:
https://github.com/More-Wrong/Factorio- ... kes_0.2.13
If you want to do it yourself, you can look at:
https://wiki.factorio.com/Prototype_definitions