1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-30 23:17:53 +02:00
ComfyFactorio/maps/fish_defender/crumbly_walls.lua
2021-03-24 19:18:46 +01:00

26 lines
770 B
Lua

local Event = require 'utils.event'
local FDT = require 'maps.fish_defender.table'
local math_random = math.random
local rock_raffle = {'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge'}
local function on_entity_died(event)
local crumbly_walls_unlocked = FDT.get('crumbly_walls_unlocked')
if not crumbly_walls_unlocked then
return
end
local entity = event.entity
if not entity.valid then
return
end
if entity.name ~= 'stone-wall' then
return
end
if math_random(1, 4) == 1 then
return
end
entity.surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = entity.position, force = 'player'})
end
Event.add(defines.events.on_entity_died, on_entity_died)