Fix scorched earth on_robot_built_entity (#7)

This commit is contained in:
2024-11-25 09:35:50 +09:00
committed by GitHub
parent 99ab54da0a
commit 683d588e83

View File

@@ -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)