Hello,
is there any Event triggering when i deconstruct/remove an entity?
Thanks for your help.
Event for Deconstruction an Entity
- Stringweasel
- Filter Inserter
- Posts: 468
- Joined: Thu Apr 27, 2017 8:22 pm
- Contact:
Re: Event for Deconstruction an Entity
Yes, there are. It would help reading the docs
https://lua-api.factorio.com/latest/def ... nes.events
For example you typically listen to these events

For example you typically listen to these events
Code: Select all
script.on_event(defines.events.on_player_mined_entity, your_function)
script.on_event(defines.events.on_robot_mined_entity, your_function)
script.on_event(defines.events.on_entity_died, your_function)
script.on_event(defines.events.script_raised_destroy, your_function)
Alt-F4 Author | Factorio Modder
Probably known for: (Configurable) Valves | Better Victory Screen | Space Spidertron | Fluidic Power
Official Contributor to Space Exploration
Probably known for: (Configurable) Valves | Better Victory Screen | Space Spidertron | Fluidic Power
Official Contributor to Space Exploration
Re: Event for Deconstruction an Entity
Hey,
thanks for the help.
I read the docs and tried some trigger but nothing happens
But then i will try it again.
thanks for the help.
I read the docs and tried some trigger but nothing happens

But then i will try it again.
Re: Event for Deconstruction an Entity
Are you sure that the event handler is really active? Add this to your control.lua:
Code: Select all
local c_name = "show-active-events"
if not commands.commands[c_name] then
commands.add_command(c_name, c_name, function(command)
local player = game.players[command.player_index]
local events = {}
for event_name, event in pairs(defines.events) do
if script.get_event_handler(event) then
events[event] = event_name
end
end
local msg = serpent.block(events)
player.print(msg)
log(msg)
end
else
error("Command \""..c_name.."\" already exists, change c_name!")
end
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
- Stringweasel
- Filter Inserter
- Posts: 468
- Joined: Thu Apr 27, 2017 8:22 pm
- Contact:
Re: Event for Deconstruction an Entity
Or it could be that you code isn't running 
Does Factorio recognise your mod? Are you placing your code in `control.lua`? How are you testing if it's running or not?

Does Factorio recognise your mod? Are you placing your code in `control.lua`? How are you testing if it's running or not?
Alt-F4 Author | Factorio Modder
Probably known for: (Configurable) Valves | Better Victory Screen | Space Spidertron | Fluidic Power
Official Contributor to Space Exploration
Probably known for: (Configurable) Valves | Better Victory Screen | Space Spidertron | Fluidic Power
Official Contributor to Space Exploration