Don't build on ores


You can't build the factory on ores, you are need to remove it before. Compatible with all mods, works in multiplayer and costs no extra UPS. (added 'resource-layer' collision mask to some buildings).

1 year, 11 months ago
0.17 - 1.1
640

b Overwriting default masks

1 year, 11 months ago

With your code as it is, it's overwriting the default masks of some entity types with what you have set as a default. You can see the default masks in the \Factorio\data\core\lualib\collision-mask-util.lua file. While many are what you are using, some are not.

I suggest adding this to the top of your file:

local collision_mask_util = require("collision-mask-util")

And then changing these lines (145-151):

if prototype.collision_mask then
    table.insert (prototype.collision_mask, "resource-layer")
    log ('added: ["' .. prototype_type_name .. '"]["' .. prototype_name .. '"]: ' .. serpent.line (prototype.collision_mask))
else
    -- prototype.collision_mask = {"item-layer", "object-layer", "player-layer", "water-tile"} -- default
    prototype.collision_mask = {"item-layer", "object-layer", "player-layer", "water-tile", "resource-layer"} -- one more
end

To this:

local collisions = collision_mask_util.get_mask(prototype)
collision_mask_util.add_layer(collisions, "resource-layer")
prototype.collision_mask = collisions
log ('added: ["' .. prototype_type_name .. '"]["' .. prototype_name .. '"]: ' .. serpent.line (prototype.collision_mask))

This allows the code (via .get_mask) to pull the current mask or appropriate default if nil, then .add_layer makes sure that it is only present once (in case another mod already added the "resource-layer" to one or more entities), and then finally you're setting the new mask table back to the prototype.

1 year, 11 months ago

Can you please apply this changings?

1 year, 11 months ago

I can, sure. Gimme a few to apply them and make sure I didn't typo anything (:P), then I'll upload it.

1 year, 11 months ago

By the way, I'm seeing some old code in here that's been commented out that appears to be related to a setting that's been commented out as well. Did you want all of that left in there, or is it ok if I clean that out?

1 year, 11 months ago

Yes, it was here to be sure that I can go back to the working code :)

1 year, 11 months ago

Ok, I left all of that alone, then.

Uploaded 1.2.12, with updated code in data-final-fixes.lua, updated info.json for version number, and added entry into changelog.txt.

1 year, 11 months ago

@FuryoftheStars
Thanks, man!

New response