Ok, I just made a very simple mod called "heighmaptest" with only 5 lines in its init.lua:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_on_generated(function(minp, maxp, seed)
if minp.y > -5 and maxp.y < 200 then
minetest.log("action"," heighmap 1 : " .. minetest.get_mapgen_object("heightmap")[1]);
end
end)
I always get "heighmap 1 : -31000" as output. Even in a completely vanilla Minetest with no other mods and no minetest.conf, just using default mapgen v6. What am I doing wrong?
EDIT: Ok, after some more testing I'm starting to understand....
The heighmap only takes into account the nodes of the currently loading chunk. This means that if your whole chunk is in the underground the heigh is just gonna be the heigh of the top of the chunk (not the surface of the world), and if your chunk happens to be somewhere in the air above the land where there are no blocks, the heigh is -31000 because it would be the same as a singlenode map for that chunk.
This means the heighmap is actually quite an unreliable way to find out where's the surface. The center of a mountain could be reported to be the height if you are unlucky enough to have checked an area of the chunk that is right behind the mountain. You would have no way to know if that heigh is actually the surface or not unless you check the chunk above to see if it's maybe all air or it's a mountain.
So what's the right way to place something in the surface then?
Maybe I will place the node at y == 5 and let the ABM that spawns the entrance carve its way up and/or down before placing the schematic. I have to add a ladder anyway.