From 44c7cae563766d136342b9e567802eb9301a2478 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Fri, 13 Oct 2023 23:51:01 +0900 Subject: [PATCH] deconstruction of tree and rocks when drive over them --- modules/addons/tree-decon.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/addons/tree-decon.lua b/modules/addons/tree-decon.lua index d4a2c206..c3d36920 100644 --- a/modules/addons/tree-decon.lua +++ b/modules/addons/tree-decon.lua @@ -96,4 +96,14 @@ Event.on_nth_tick(300, function() for key, _ in pairs(chache) do chache[key] = nil end -end) \ No newline at end of file +end) + +Event.add(defines.events.on_entity_damaged, function(event) + if not (event.damage_type.name == 'impact' and event.force) then + return + end + + if event.entity.type == 'tree' or event.entity.type == 'simple-entity' then + event.entity.destroy() + end +end)