mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-14 10:13:13 +02:00
Merge pull request #395 from iltar/fix-stone-drop-on-death
Fix stone drop on death
This commit is contained in:
commit
9555fd1e6a
@ -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, cause = event.cause, force = event.force})
|
||||
entity.destroy()
|
||||
end
|
||||
end)
|
||||
|
||||
local enable_digging_warning = config.enable_digging_warning
|
||||
|
||||
Event.add(defines.events.on_player_mined_entity, function (event)
|
||||
|
Loading…
Reference in New Issue
Block a user