Catch nuke explosion event

Place to get help with not working mods / modding interface.
Post Reply
starholme
Fast Inserter
Fast Inserter
Posts: 201
Joined: Tue Oct 21, 2014 7:25 pm
Contact:

Catch nuke explosion event

Post 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?

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2530
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Catch nuke explosion event

Post by FuryoftheStars »

My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

starholme
Fast Inserter
Fast Inserter
Posts: 201
Joined: Tue Oct 21, 2014 7:25 pm
Contact:

Re: Catch nuke explosion event

Post 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!

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Catch nuke explosion event

Post 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.
Image

BicycleEater
Fast Inserter
Fast Inserter
Posts: 153
Joined: Sun Jul 26, 2020 4:05 pm
Contact:

Re: Catch nuke explosion event

Post 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

Post Reply

Return to “Modding help”