I then keep track of a table with what trees need to be placed so I can do a place schematic on voxel manip call after the terrain has been created. But for some reason some of the trees are floating ... Especially around steeper terrain.
The code (at least, the relevant snippets). First, the loop setting x, y, z:
Code: Select all
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
<snip>
for y = minp.y-1, maxp.y+1 do
Code: Select all
data[ivm] = node["default:dirt_with_snow"]
Code: Select all
table.insert(generate_trees, {pos, minetest.get_modpath("default").."/schematics/pine_tree.mts"})
Code: Select all
for i = 1, #generate_trees do
minetest.place_schematic_on_vmanip(vm, generate_trees[i][1], generate_trees[i][2], "random", nil, false)
end
Spoiler
Spoiler
Spoiler
I tried a ystride and testing when I hit a data[ivm] ~= node["air"] before storing the position. This resulted in all trees (steep terrain or flat terrain) being sunk into the ground... This I also do not get as striding down should hit data as it generates from negative y upwards to positive y (so striding from positive to negative I should see the nodes that had been set ...?) Obviously offsetting y also did not work, it "solves" the problem for steep terrain but then trees on flat terrain are sunk.
So ... What am I doing wrong? O_o
Full code https://github.com/evrooije/beerarchy/t ... nderworlds in mapgen.lua and undergen.lua (not the nicest code for now sorry, currently it is a huge if else but am actually considering something different ...)