Page 1 of 1

Map generator doesn't place trees in the middle of tiles

Posted: Sun Nov 11, 2018 4:46 pm
by darkfrei
Rseding91 wrote:
Sun Nov 11, 2018 4:11 pm
Thanks for the report. I've improved the error for 0.17. It's actually checking that:

If you have shadows defined: shadow frame count must be == leaves frame count + 1

If you don't have shadows defined: trunk frame count must be == leaves frame count + 1
There is a lot of problems with trees:
darkfrei wrote:
Sun Nov 11, 2018 2:44 pm
Also, now leaf_generation and branch_generation cannot be nil, there is another error.
And this one:
If I have tree.collision_box = {{-0.7, -0.7}, {0.7, 0.7}} then I get:
2018-11-11 16_03_48-Factorio 0.16.51.png
2018-11-11 16_03_48-Factorio 0.16.51.png (23.57 KiB) Viewed 4227 times
If I change it to tree.collision_box = {{-0.2, -0.2}, {0.2, 0.2}} then I expect:
2018-11-11 16_08_05-Factorio 0.16.51_01.png
2018-11-11 16_08_05-Factorio 0.16.51_01.png (6.47 KiB) Viewed 4227 times
but I get:
2018-11-11 16_08_05-Factorio 0.16.51.png
2018-11-11 16_08_05-Factorio 0.16.51.png (15.36 KiB) Viewed 4227 times
So I cannot place then in the middle of tiles.

Re: Cannot place trees in the middle of tiles

Posted: Sun Nov 11, 2018 5:14 pm
by posila
Split thread from: 63407

It's impossible to help you, because you didn't say what you're doing.

Creating trees in middle of tiles just works:
trees-on-middle-of-tile.png
trees-on-middle-of-tile.png (963.15 KiB) Viewed 4213 times

Re: Cannot place trees in the middle of tiles

Posted: Sun Nov 11, 2018 5:46 pm
by darkfrei
posila wrote:
Sun Nov 11, 2018 5:14 pm
Split thread from: 63407

It's impossible to help you, because you didn't say what you're doing.

Creating trees in middle of tiles just works:
trees-on-middle-of-tile.png
I want to get same result, but this code cannot help me:

Code: Select all

for i, tree in pairs (data.raw.tree) do
  tree.flags = {"placeable-neutral", "breaths-air"} -- as you see,  no "placeable-off-grid" here
  tree.collision_box = {{-0.2, -0.2}, {0.2, 0.2}} -- it's less then 1 x 1 tile
end
I need exactly that, what you have on the image. But with standard autoplacement, not by the script.

I expect that all trees will be placed same way like insterters and chests, in the middle of tiles, but all of them are placed on the edge of tiles.

Re: Cannot place trees in the middle of tiles

Posted: Sun Nov 11, 2018 5:49 pm
by darkfrei
In the wiki you can find also this method to change the size of entity:

Code: Select all

  tree.tile_width = 1
  tree.tile_height = 1
but it's does not work.

Re: Cannot place trees in the middle of tiles

Posted: Sun Nov 11, 2018 6:05 pm
by posila
Got it. Your expected behavior is that map generator will place entities that don't have "placeable-off-grid" aligned to grid same way as if it was built by player.

I was not sure how you were creating trees to be aligned to center of a tile (I thought you were placing them manually through script, or you tried to allow player to plant trees, or something like that ...)

Re: Cannot place trees in the middle of tiles

Posted: Mon Nov 12, 2018 10:18 am
by darkfrei
posila wrote:
Sun Nov 11, 2018 6:05 pm
Got it. Your expected behavior is that map generator will place entities that don't have "placeable-off-grid" aligned to grid same way as if it was built by player.
The map generator places all entities (without "placeable-off-grid") less than 1x1 in the middle of tiles, all entities less than 2x2 to the lines crossing.

It works for ores, spawners, rocks another entities, but not for trees.

Re: Map generator doesn't place trees in the middle of tiles

Posted: Mon Jan 07, 2019 5:52 am
by Rseding91
Looking at the map generation logic if an entity isn't a resource entity and it doesn't have "placable-off-grid" it's generated at exact grid coordinates (no decimal) meaning it will never generate an entity that isn't placable off grid on a non-integer position. So in that regard I'm not sure what you mean by "It works for ores, spawners, rocks another entities, but not for trees." because unless I completely missed something it *doesn't* work for spawners, rocks, or any other entity.

Re: Map generator doesn't place trees in the middle of tiles

Posted: Mon Jan 07, 2019 5:56 am
by Rseding91
With that said: it seems like map generation completely ignores the grid-buildability logic of all entities and just throws them on the map as it sees fit. I could change it, but I don't know if it would break other things.

Re: Map generator doesn't place trees in the middle of tiles

Posted: Mon Jan 07, 2019 8:05 am
by darkfrei
Rseding91 wrote:
Mon Jan 07, 2019 5:56 am
With that said: it seems like map generation completely ignores the grid-buildability logic of all entities and just throws them on the map as it sees fit. I could change it, but I don't know if it would break other things.
I've tried map generator and all rocks 1x1 tiles are placed in the middle of tiles {x=x+0.5, y=y+0.5}, rocks 2x2 tiles are placed on the tiles crossing {x=x,y=y}, rocks 3x3 the same as 1x1. It doesn't work only for trees.

Re: Map generator doesn't place trees in the middle of tiles

Posted: Mon Jan 07, 2019 4:46 pm
by posila
I think it should be OK to align entities the same way manual building does, so I changed it. Let's see what happens.

Don't know why it would work for stones or other things, I have not tested it in 0.16, but in 0.17 before the fix it would not align them to middle of tile either.