1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-04 00:15:45 +02:00
ComfyFactorio/maps/fish_defender_v1/crumbly_walls.lua
2024-10-22 21:47:11 +02:00

24 lines
666 B
Lua

local Event = require 'utils.event'
local math_random = math.random
local rock_raffle = { 'big-sand-rock', 'big-rock', 'big-rock', 'big-rock', 'huge-rock' }
local function on_entity_died(event)
if not storage.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)