1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-06 00:23:49 +02:00
ComfyFactorio/maps/scrap_towny_ffa/turrets_drop_ammo.lua
2022-10-22 22:13:35 +02:00

18 lines
590 B
Lua

local Event = require 'utils.event'
local math_random = math.random
local math_min = math.min
local function on_entity_died(event)
local entity = event.entity
local surface = entity.surface
if entity.type == 'ammo-turret' and entity.force.name == 'enemy' then
local min = math_min(entity.get_item_count('piercing-rounds-magazine'), 20)
if min > 0 then
surface.spill_item_stack(entity.position, {name = 'piercing-rounds-magazine', count = math_random(1, min)}, true)
end
end
end
Event.add(defines.events.on_entity_died, on_entity_died)