diff --git a/exp_legacy/module/modules/addons/scorched-earth.lua b/exp_legacy/module/modules/addons/scorched-earth.lua index 5ef34e22..f71881f6 100644 --- a/exp_legacy/module/modules/addons/scorched-earth.lua +++ b/exp_legacy/module/modules/addons/scorched-earth.lua @@ -88,25 +88,14 @@ Event.add(defines.events.on_player_changed_position, function(event) end) -- When an entity is build there is a much higher chance that the tiles will degrade -Event.add(defines.events.on_built_entity, function(event) - local entity = event.created_entity - local surface = entity.surface - local position = entity.position - local strength = get_tile_strength(surface, position) +local function on_built_entity(event) + local entity = event.entity + local strength = get_tile_strength(entity.surface, entity.position) if not strength then return end if get_probability(strength) * config.weakness_value > math.random() then degrade_entity(entity) end -end) +end --- Same as above but with robots -Event.add(defines.events.on_robot_built_entity, function(event) - local entity = event.created_entity - local surface = entity.surface - local position = entity.position - local strength = get_tile_strength(surface, position) - if not strength then return end - if get_probability(strength) * config.weakness_value > math.random() then - degrade_entity(entity) - end -end) +Event.add(defines.events.on_built_entity, on_built_entity) +Event.add(defines.events.on_robot_built_entity, on_built_entity)