This is a request for a way to see when a cliff is being destroyed.
currently the only events raised are when the cliff exposive is thrown
on_pre_robot_exploded_cliff and
on_player_used_capsule
or after the cliff is dead already
on_robot_exploded_cliff (no way to tell when a player thown explosive lands)
what I am looking for is something from right before the cliff is destroyed kind of like how on_entity_died is before the death and on_post_entity_died is after
currently this is doable only by listing for where the capsle is thrown and checking every tick for if the target cliff still exists, easy to get desyncs or memory leaks.
Edit: I have confirmed using https://mods.factorio.com/mod/0-event-trace that no event is raised at all for destruction of a cliff if the explosive is thrown by the player
Allow event for a cliff being destroyed
-
- Inserter
- Posts: 44
- Joined: Sat Dec 14, 2019 3:26 am
- Contact:
Re: Allow event for a cliff being destroyed
You can use script.register_on_entity_destroyed to detect this for now. I'll look into a more proper solution for 2.0.
Don't forget, you're here forever.
Re: Allow event for a cliff being destroyed
What you also could do is to add a script trigger event to the capsule:
And then use the event:
I figured out, that the on_script_trigger_effect event is called before on_entity_destroyed, so you could use this to temporarily save all relevant entity data (all entities in blast radius) in a table either when on_script_trigger_effect or on_player_used_capsule is called and access them in on_entity_destroyed, because you will not be able to retrieve entity position or other data in there.
Code: Select all
table.insert(data.raw.projectile["cliff-explosives"].action[1].action_delivery.target_effects, {
type = "script",
effect_id = "cliff-explosives"
})
Code: Select all
script.on_event(defines.events.on_script_trigger_effect, function(event)
if event.effect_id == "cliff-explosives" then
-- stuff
end
end)