1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

Prevent rocks from dying and spilling on dmg taken

This commit is contained in:
Lynn 2018-11-18 19:15:45 +01:00
parent 7fa48bc583
commit 7b51db1ac0

View File

@ -13,6 +13,7 @@ local ScoreTable = require 'map_gen.Diggy.ScoreTable'
local Debug = require 'map_gen.Diggy.Debug'
local insert = table.insert
local random = math.random
local raise_event = script.raise_event
-- todo remove this dependency
local ResourceConfig = require 'map_gen.Diggy.Config'.features.ScatteredResources
@ -67,7 +68,8 @@ end
@param entity LuaEntity
]]
local function diggy_hole(entity)
if ((entity.name ~= 'sand-rock-big') and (entity.name ~= 'rock-huge')) then
local name = entity.name
if name ~= 'sand-rock-big' and name ~= 'rock-huge' then
return
end
@ -230,6 +232,20 @@ function DiggyHole.register(config)
diggy_hole(event.entity)
end)
Event.add(defines.events.on_entity_damaged, function (event)
local entity = event.entity
local name = entity.name
if name ~= 'sand-rock-big' and name ~= 'rock-huge' then
return
end
if entity.health == 0 then
raise_event(defines.events.on_entity_died, {entity = entity})
entity.destroy()
end
end)
local enable_digging_warning = config.enable_digging_warning
Event.add(defines.events.on_player_mined_entity, function (event)