1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-08 00:39:30 +02:00
ComfyFactorio/modules/splice_double.lua

28 lines
791 B
Lua
Raw Normal View History

2019-02-14 16:44:12 +02:00
-- biters splice into two -- by mewmew
2021-03-24 21:14:55 +02:00
local Event = require 'utils.event'
2019-02-14 16:44:12 +02:00
local biter_fragmentation = {
2021-03-24 17:46:00 +02:00
['medium-biter'] = 'small-biter',
['big-biter'] = 'medium-biter',
['behemoth-biter'] = 'big-biter'
}
2019-02-14 16:44:12 +02:00
2021-03-24 17:46:00 +02:00
local function on_entity_died(event)
if not event.entity.valid then
return
end
if biter_fragmentation[event.entity.name] then
local entity = event.entity
2021-03-24 21:14:55 +02:00
for _ = 1, 2, 1 do
2021-03-24 17:46:00 +02:00
local p = entity.surface.find_non_colliding_position(biter_fragmentation[entity.name], entity.position, 3, 0.5)
if p then
entity.surface.create_entity({name = biter_fragmentation[entity.name], position = p})
end
end
return
end
2019-02-14 16:44:12 +02:00
end
2021-03-24 17:46:00 +02:00
2021-03-24 21:14:55 +02:00
Event.add(defines.events.on_entity_died, on_entity_died)