However, there also exists a utility constant default_collision_masks. The two are defined in different places and may possibly not match up (though i haven't checked). The problem however, is that the utility constant can be changed by mods, while any changes to the table returned by collision-mask-defaults.lua will reset after each data stage. And after that, they will definitely not match for some time, even if the mod accounted for this weirdness.
In one of my mods, posted signals, i have to fix collision-mask-defaults.lua at every stage, to give other mods a better idea of what masks are used.
Code: Select all
for _, type in pairs{'rail-signal', 'rail-chain-signal'} do
for _, prototype in pairs(data.raw[type]) do
if prototype.collision_mask then
prototype.collision_mask.layers['rail_signal'] = true
end
if prototype.elevated_collision_mask then
prototype.elevated_collision_mask.layers['rail_signal'] = true
end
end
end
-- I shouldn't need to do this in every stage
local collision_mask_defaults = require("__core__/lualib/collision-mask-defaults")
collision_mask_defaults['rail-signal'].layers['rail_signal'] = true
collision_mask_defaults['rail-chain-signal'].layers['rail_signal'] = true
collision_mask_defaults['rail-signal/elevated'].layers['rail_signal'] = true
collision_mask_defaults['rail-chain-signal/elevated'].layers['rail_signal'] = true
I propose that collision-mask-defaults.lua should just return the value from the utility constants and/or for collision-mask-util.lua to use utility constants directly. collision-mask-defaults.lua could be removed, but it can be kept for backwards compatibility.
