when I try to remove a corpse entity on the "on_trigger_created_entity" event it trow this error
Code: Select all
LuaEntity API call when LuaEntity was invalid
the entity :
Code: Select all
data:extend({
{
type = "corpse",
name = "extinguisher-remnants",
icon = "__base__/graphics/icons/remnants.png",
flags = {"placeable-neutral", "not-on-map"},
selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
tile_width = 1,
tile_height = 1,
selectable_in_game = false,
subgroup = "remnants",
order="d[remnants]-a[generic]-a[small]",
time_before_removed = 60 * 60 * 5, -- 15 minutes
final_render_layer = "lower-object",
animation =
{
[...]
}
},
})
Code: Select all
local function extinguish_fire(event)
if event.entity.name == 'extinguisher-remnants' then
local position = event.entity.position;
local area_start = {position.x - 1, position.y - 1}
local area_end = {position.x + 1, position.y + 1}
for _, entity in pairs(game.surfaces['nauvis'].find_entities{area_start, area_end}) do
if entity.type == 'fire' then
entity.destroy()
end
if entity.type == 'transport-belt' then
event.entity.destroy() -- THIS CAUSE THE CRASH
end
end
end
end
script.on_event(defines.events.on_trigger_created_entity, extinguish_fire)
Thanks!