dying_trigger_effect: if a unit dies on a certain tile, replace that tile with another
Posted: Mon Sep 19, 2022 6:57 am
I'm trying to suss this out: if a unit dies on a `garbageFill` or a `sacrificezoneFill`, it should replace that tile with a landfill tile. I haven't so far been able to find the correct combination of collision masks. Perhaps some other mechanism exists?
Code: Select all
local CollisionMaskUtil = require("__core__.lualib.collision-mask-util");
local layer1 = CollisionMaskUtil.get_first_unused_layer();
-- you CAN pave over Garbage
local garbageFillMask = {layer1}
-- you CAN NOT pave over a Sacfice Zone
local sacrificeZoneMask = {layer1, "water-tile", "floor-layer", "item-layer", "object-layer"}
for _, unit in pairs(data.raw.unit) do
if not unit.dying_trigger_effect then
unit.dying_trigger_effect = {};
end
table.insert(unit.dying_trigger_effect, {
type = "set-tile",
tile_name = "landfill",
radius = 5,
apply_projection = true,
tile_collision_mask = {layer1}; -- {"water-tile", "floor-layer", "item-layer", "object-layer"}
});
data:extend({unit});
end