If I hit it, it dies.
If I hit it, it dies.
I want a mod that will automatically mark for harvest any tree, rock or cliff that I run a vehicle into.
Re: If I hit it, it dies.
Just place this code to your mod into the control.lua:nljr wrote: Sat May 23, 2020 11:28 pm I want a mod that will automatically mark for harvest any tree, rock or cliff that I run a vehicle into.
Code: Select all
script.on_event(defines.events.on_entity_damaged, function(event)
local entity = event.entity
local force = event.force
if entity.type == "tree" and force then
entity.order_deconstruction(force)
end
end)
Re: If I hit it, it dies.
This would also mark burning trees for deconstruction, which would kill a lot of robots.
Re: If I hit it, it dies.
You are right, it must be impact only.ichVII wrote: Sun Jun 14, 2020 1:17 pm This would also mark burning trees for deconstruction, which would kill a lot of robots.
Code: Select all
script.on_event(defines.events.on_entity_damaged, function(event)
local entity = event.entity
local force = event.force
if entity.type == "tree" and event.damage_type.name == "impact" and force then
entity.order_deconstruction(force)
end
end)