Page 1 of 1

[0.13.11] Floor-layer alone in collision mask not working

Posted: Thu Jul 28, 2016 10:09 pm
by Neemys
As I was working on my mod, I found a weird thing when using collision mask (I use them to block the placement of some building).

When you set the collision mask of a building to floor-layer and nothing else, this building doesn't collide with the floor-layer if terrain is set to collide with floor layer. But if the building have floor-layer and another layer, it is blocked as expected.

To demonstrate it I wrote a little mod with only the following code in it :

Code: Select all



local tiles = data.raw["tile"];
-- add floor layer to collision mask of all non minable tile (terrain mostly)
for name,item in pairs(tiles) do
	if not item.minable then
		if item.collision_mask then
			table.insert(item.collision_mask, "floor-layer");
		else
			item.collision_mask = {  "floor-layer"}
		end;
	end
end

data.raw["furnace"]["stone-furnace"].collision_mask  = {  "floor-layer"}
data.raw["furnace"]["steel-furnace"].collision_mask  = { "player-layer"}
data.raw["furnace"]["electric-furnace"].collision_mask  = {  "floor-layer","player-layer"}
As all non minable tile are set to collide with floor-layer, I expect any building which collide with floor-layer to be not placeable on terrain.

Using the mod provided as attachment. We obtain those result :
Stone furnace should collide with terrain
Stone furnace should collide with terrain
stone1.jpg (39.42 KiB) Viewed 1209 times
The stone furnace which have ONLY floor-layer in collision mask should collide with terrain, it is not. It does not collide with player, it's normal.


steel furnace does collide with player but not terrain
steel furnace does collide with player but not terrain
steel1.jpg (37.04 KiB) Viewed 1209 times
Steel furnace which have ONLY player-layer in collision mask collide with player but not terrain. It's normal, just showing that it's not player-layer that block placement in the next screenshot.


electric furnace collide with terrain as expected
electric furnace collide with terrain as expected
electric.jpg (32.98 KiB) Viewed 1209 times
Electric furnace which have floor-later AND player-layer collide with terrain.



Expected behavior : stone surnace which have floor-layer in mask should not be placeable on terrain (as terrain block floor-layer with the mod) like the electric furnace.


Edit : In case you are wondering,if I try to place the stone furnace on the ground it succeed (it should not)

Re: [0.13.11] Floor-layer alone in collision mask not working

Posted: Tue Aug 02, 2016 10:26 am
by Rseding91
floor-layer is not tiles. Floor-layer is used for things like rails, gates, and belts.

you want ground-tile which is tiles.

Specifically for performance reasons collision mask checks against tiles doesn't run unless it contains one of the following collision mask values:

water-tile
ground-tile
resource-layer
player-layer
item-layer
doodad-layer

Re: [0.13.11] Floor-layer alone in collision mask not working

Posted: Tue Aug 02, 2016 5:47 pm
by Neemys
I knew that floor-layer wasn't for tile, It's just before you add us some nice new mask (I thank you again for that) we have no choice to use one used by the game. (ground-tile wasn't working for my case)

So now I'm using layer-10 and add player-layer as well to force collision check. So like you say, not a bug because it's for performance reason.