Post your modding questions here
- rubenwardy
- Moderator
- Posts: 6972
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Post your modding questions here
This is, afaik, due to overgeneration, which causes the c++ mapgen to override your blocks. Paramat is the one to talk to about this.
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
ls overgeneration also the reason for usual trees in the meow heaven?rubenwardy wrote:This is, afaik, due to overgeneration, which causes the c++ mapgen to override your blocks. Paramat is the one to talk to about this.
- Attachments
-
- nhvbugtree.png (303.34 KiB) Viewed 797 times
- paramat
- Developer
- Posts: 3700
- Joined: Sun Oct 28, 2012 00:05
- GitHub: paramat
- IRC: paramat
- Location: UK
Re: Post your modding questions here
Hybrid Dog yes probably.
All core mapgens work on the 80^3 node mapchunk plus a 16 node deep shell that extends into / overlaps neighbouring mapchunks. Dungeons, large caves and mgv6 dirt/grass all 'overgenerate' into the shell sometimes.
In your code emin emax are the shell limits, minp maxp are the mapchunk limits try:
It might help.
All core mapgens work on the 80^3 node mapchunk plus a 16 node deep shell that extends into / overlaps neighbouring mapchunks. Dungeons, large caves and mgv6 dirt/grass all 'overgenerate' into the shell sometimes.
In your code emin emax are the shell limits, minp maxp are the mapchunk limits try:
Code: Select all
local data = vm:get_data(emin, emax)
for i in area:iterp(emin, emax) do
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
it would cause unnecessary lag, l guess, the map would become generated more than one time at the same placeparamat wrote:Hybrid Dog yes probably.
All core mapgens work on the 80^3 node mapchunk plus a 16 node deep shell that extends into / overlaps neighbouring mapchunks. Dungeons, large caves and mgv6 dirt/grass all 'overgenerate' into the shell sometimes.
In your code emin emax are the shell limits, minp maxp are the mapchunk limits try:
It might help.Code: Select all
local data = vm:get_data(emin, emax) for i in area:iterp(emin, emax) do
Re: Post your modding questions here
Thanks, and sorry for the late reply, but forceload is a mechanism to keep a block loaded "forever", right? So that's not what I'm looking for. Thanks, though!Hybrid Dog wrote: as far as l know the client needs to load the chunk, not the server
there's a function to forceload a chunk: dev.minetest.net/minetest.forceload_block
Re: Post your modding questions here
I haven't tested your code, but since you are calculating next_hotspot in all 3 dimensions, wouldn't a new block be created in the same area in the surface when a chunk gets generated further down close to the hotspot below?Sane wrote:Code: Select all
--[[ Node placer - Places a node on the surface, at a random position in the mg block that contains a grid point defined by cell_size published under Creative Commons CC0 license. --]] -- cell_size must be bigger then mg block size (80) to work. local cell_size = 150 local item_id = minetest.get_content_id("default:steelblock") minetest.register_on_generated(function(minp, maxp, seed) -- If the next_hotspot is not within this mg block then exit local next_hotspot = { x = math.ceil(minp.x / cell_size) * cell_size, y = math.ceil(minp.y / cell_size) * cell_size, z = math.ceil(minp.z / cell_size) * cell_size } if next_hotspot.x > maxp.x or next_hotspot.y > maxp.y or next_hotspot.z > maxp.z then return end -- Place the object somewhere in this block local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") local va = VoxelArea:new{MinEdge=emin, MaxEdge=emax} local vd = vm:get_data() local r = PcgRandom(seed) -- this ensures that you get the same results each time you generate the world anew. local item_pos = { x = r:next(minp.x, maxp.x), y = r:next(minp.y, maxp.y), z = r:next(minp.z, maxp.z), } -- This is to optimize, because getting the height map is expensive if minp.y > -200 and maxp.y < 200 then local hm = minetest.get_mapgen_object("heightmap") local hz = (item_pos.z - minp.z) * 80 local hx = (item_pos.x - minp.x) % 80 local height = hm[1 + hx + hz] item_pos.y = height + 1 end vd[va:indexp(item_pos)] = item_id -- vm:set_data(vd) --vm:calc_lighting() --vm:update_liquids() vm:write_to_map() --vm:update_map() -- end)
I know you have checks to avoid placing it in the surface if it's below -200 and above 200 but with a cell_size of 150 you still can have 2 hotspots in there.
Also, if it's below -200 or above 200, it would place the node in a random location, even if it's in the sky or underground, no?
Re: Post your modding questions here
Maybe those nodes where generated after your mod already ran. Do you have default in your depends.txt.GunshipPenguin wrote:This code does work, but I find that certian nodes are not replaced by limit:limit_node like I want them to be.
Trying to stay me.
Re: Post your modding questions here
The hotspot is a single coordinate so it can only be in one mapgen block.Ferk wrote:I haven't tested your code, but since you are calculating next_hotspot in all 3 dimensions, wouldn't a new block be created in the same area in the surface when a chunk gets generated further down close to the hotspot below?
No, the purpose of of the checks is to avoid getting the hightmap unnecessarily. Just a performance thing.Ferk wrote:I know you have checks to avoid placing it in the surface if it's below -200 and above 200 ...
Yes this is what it does.Ferk wrote:Also, if it's below -200 or above 200, it would place the node in a random location, even if it's in the sky or underground, no?
Trying to stay me.
Re: Post your modding questions here
Yes, but after each hotspot is found, a node is placed at the surface (using the heightmap) whenever the chunk that is getting generated is between -200 and 200 (the node in the surface might not be part of the chunk generated).Sane wrote:The hotspot is a single coordinate so it can only be in one mapgen block.
If this is the case then it's possible for 2 nodes to be placed at heightmap level next to each other, even though the goal was to have them separated by 150 nodes. The hotspots might be separated by that much (in the Y axis), but not the nodes you are placing.
I think it would be better to calculate 2D hotspots(only X and Z coordinates) and then after getting the heightmap check that the node is within the chunk that you are generating before placing it. That way you ensure you only place one node once on each X-Z division and only at surface level.
I know, the fact that this also limits the amount of nodes that get placed in the surface is just an after-effect. Perhaps because you added this it's less noticeable, since only 2 nodes would be created on each 150x150 area in the surface. But still there's a chance they would be next to each other (also, even though the area is 150 the randomness in the X and Z axis when placing the node is limited to the currently generating chunk, which might not be that big).Sane wrote:No, the purpose of of the checks is to avoid getting the hightmap unnecessarily. Just a performance thing.
Re: Post your modding questions here
I just tested it and it does place 2 nodes close together. I found 3 within a 50 node radius.
The question is how to fix this. I need the nodes to be seperated. If they are close then it will cause an issue with what they do.
Thanks for all your help on this!
The question is how to fix this. I need the nodes to be seperated. If they are close then it will cause an issue with what they do.
Thanks for all your help on this!
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!
A list of my mods can be found here
A list of my mods can be found here
Re: Post your modding questions here
That's right.Ferk wrote:Yes, but after each hotspot is found, a node is placed at the surface (using the heightmap) whenever the chunk that is getting generated is between -200 and 200 (the node in the surface might not be part of the chunk generated).Sane wrote:The hotspot is a single coordinate so it can only be in one mapgen block.
If this is the case then it's possible for 2 nodes to be placed at heightmap level next to each other, even though the goal was to have them separated by 150 nodes. The hotspots might be separated by that much, but not the nodes you are placing.
The code is a reply to Don, who wanted to place a node at a 1000 nodes spacing. The intend of the source is to give an general impression on how to go about to solve a thing like that. It is not thought to be the solution.
Thank you for your interest. Feel free to optimize and extend the code to a working condition.
Trying to stay me.
Re: Post your modding questions here
That's odd. That should not be possible.Don wrote:I just tested it and it does place 2 nodes close together. I found 3 within a 50 node radius.
Could you send the coordinates and the grid size you test with?
The code places the node within a mapgen block. That is a 80x80x80 volume. So if you stay with a 1000er spacing you should be safe,Don wrote:The question is how to fix this. I need the nodes to be seperated. If they are close then it will cause an issue with what they do.
You are very welcome.Don wrote:Thanks for all your help on this!
Trying to stay me.
Re: Post your modding questions here
Yes, I know. And thanks for that, I'm interested as well because something like this would also be useful for my project. I would like to place an entrance to an underground dungeon in the surface in specific X,Z positions at fixed distances.Sane wrote:The code is a reply to Don, who wanted to place a node at a 1000 nodes spacing. The intend of the source is to give an general impression on how to go about to solve a thing like that. It is not thought to be the solution.
This is what I'm doing in my register_on_generated for that:
Code: Select all
if (minp.y > dungeon_rooms.origin.y) then
-- avoid the calculation when too high up
if (minp.y > 200) then return end
local cell_size = {
x = dungeon_rooms.stairs_distance * dungeon_rooms.room_area.x,
z = dungeon_rooms.stairs_distance * dungeon_rooms.room_area.z,
}
local next_entrance = {
x = maxp.x - (maxp.x % cell_size.x),
z = maxp.z - (maxp.z % cell_size.z),
}
if (minp.x < next_entrance.x) and (minp.z < next_entrance.z) then
-- Put the entrance spawner on ground level
local hm = minetest.get_mapgen_object("heightmap")
local hz = (next_entrance.z - minp.z) * 80
local hx = (next_entrance.x - minp.x) % 80
next_entrance.y = hm[1 + hx + hz]
-- But only if it's in the generating chunk
if (next_entrance.y < maxp.y) and (next_entrance.y > minp.y) then
minetest.set_node(next_entrance, minetest.get_content_id("dungeon_rooms:entrance_spawner"))
end
end
else
[......]
end
Re: Post your modding questions here
I screwed up. I commented out the part of my code. I still had nodes spawning.
I have just your code running now. I have been looking for around a half hour and can not find one. I will let you know if I do find one. I have to make supper now. I will get back to it this evening.
I have just your code running now. I have been looking for around a half hour and can not find one. I will let you know if I do find one. I have to make supper now. I will get back to it this evening.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!
A list of my mods can be found here
A list of my mods can be found here
Re: Post your modding questions here
Can you print out the value of your coordinates, or at least the item_pos.y after the heighmap calculation?Don wrote:I have been looking for around a half hour and can not find one.
Code: Select all
minetest.log("action","Placing node at " .. item_pos.x .. ",".. item_pos.y .. ",".. item_pos.z)
I can't find proper documentation regarding minetest.get_mapgen_object("heightmap").
Also, how sure can we be that a chunk is gonna be 80x80? there's a "chunksize" configuration option in minetest.conf. Potentially, a mapgen relying on a hardcoded 80x80 chunk size could be messed up if people changed their settings. Maybe we should use "(maxp.x - minp.x)"
Re: Post your modding questions here
It is saying that it is placing a node but when I check the location there is nothing there.
Code: Select all
2015-09-24 17:33:06: ACTION[Emerge-0]: Placing node at 1962,-4,-2100
action Placing node at 1962,-4,-2100
2015-09-24 17:33:06: ACTION[Emerge-0]: Placing node at 1784,10,-2053
action Placing node at 1784,10,-2053
2015-09-24 17:33:12: ACTION[Emerge-0]: Placing node at 1742,-4,-2197
action Placing node at 1742,-4,-2197
2015-09-24 17:33:14: ACTION[Emerge-0]: Placing node at 1944,0,-2207
action Placing node at 1944,0,-2207
2015-09-24 17:33:22: ACTION[Emerge-0]: Placing node at 1754,7,-2368
action Placing node at 1754,7,-2368
2015-09-24 17:33:24: ACTION[Emerge-0]: Placing node at 1956,15,-2390
action Placing node at 1956,15,-2390
2015-09-24 17:33:38: ACTION[Emerge-0]: Placing node at 1676,12,-2353
action Placing node at 1676,12,-2353
2015-09-24 17:33:39: ACTION[Emerge-0]: Placing node at 1699,-7,-2582
action Placing node at 1699,-7,-2582
2015-09-24 17:33:40: ACTION[Emerge-0]: Placing node at 1767,12,-2590
action Placing node at 1767,12,-2590
2015-09-24 17:33:49: ACTION[Emerge-0]: Placing node at 1696,48,-2726
action Placing node at 1696,48,-2726
2015-09-24 17:33:50: ACTION[Emerge-0]: Placing node at 1765,48,-2748
action Placing node at 1765,48,-2748
2015-09-24 17:33:54: ACTION[Emerge-0]: Placing node at 1540,17,-2518
action Placing node at 1540,17,-2518
2015-09-24 17:33:56: ACTION[Emerge-0]: Placing node at 1564,5,-2709
action Placing node at 1564,5,-2709
2015-09-24 17:35:46: ACTION[Emerge-0]: Placing node at 1329,9,-2690
action Placing node at 1329,9,-2690
2015-09-24 17:35:56: ACTION[Emerge-0]: Placing node at 1362,19,-2533
action Placing node at 1362,19,-2533
2015-09-24 17:36:00: ACTION[Emerge-0]: Placing node at 1241,4,-2549
action Placing node at 1241,4,-2549
2015-09-24 17:36:01: ACTION[Emerge-0]: Placing node at 1212,-2,-2748
action Placing node at 1212,-2,-2748
2015-09-24 17:36:39: ACTION[Emerge-0]: Placing node at 1402,-4,-2839
action Placing node at 1402,-4,-2839
2015-09-24 17:36:40: ACTION[Emerge-0]: Placing node at 1185,-19,-2882
action Placing node at 1185,-19,-2882
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!
A list of my mods can be found here
A list of my mods can be found here
Re: Post your modding questions here
Strange. The minetes.log line is right before setting The "vd[va:indexp(item_pos)]" value, right? The node should be there then if you do vm:set_data and vm:write_to_map.. And your Y coordinates look reasonable, not sure why mines are so off.Don wrote:It is saying that it is placing a node but when I check the location there is nothing there.
Perhaps my underground mapgen messes up The heightmap calculation?
Re: Post your modding questions here
I had the minetest.log in a different spot. I moved it but got the same result. I can give myself the node and place it in the world. I have an abm running to place a schematic when it finds the node. When I place the node the schematic is placed. I am watching the terminal and seeing the node being placed like the code says above but I can not find any. I have checked it with mapgen v6 and v7. Both were new maps with no other mods running. I am not getting any errors in debug.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!
A list of my mods can be found here
A list of my mods can be found here
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
there's a better wayBen wrote:Thanks, and sorry for the late reply, but forceload is a mechanism to keep a block loaded "forever", right? So that's not what I'm looking for. Thanks, though!Hybrid Dog wrote: as far as l know the client needs to load the chunk, not the server
there's a function to forceload a chunk: dev.minetest.net/minetest.forceload_block
https://github.com/minetest/minetest/co ... t-13428878
obviously calling the vmanip:read_from_map(minp,maxp) makes minetest. Get node work in those chunk(s).
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
maybe you somewhere didn't round the position before using it for the area indexFerk wrote:Strange. The minetes.log line is right before setting The "vd[va:indexp(item_pos)]" value, right? The node should be there then if you do vm:set_data and vm:write_to_map.. And your Y coordinates look reasonable, not sure why mines are so off.Don wrote:It is saying that it is placing a node but when I check the location there is nothing there.
Perhaps my underground mapgen messes up The heightmap calculation?
Re: Post your modding questions here
You mean for my case or for Don's?Hybrid Dog wrote:maybe you somewhere didn't round the position before using it for the area index
In my case, even though I use an area index for checking the heighmap (not for placing the node itself, since I'm not using voxelmanip), I've even tried printing straight "minetest.get_mapgen_object("heightmap")[1]" in the on_generated and even that returns -31000. It's not just that the Y coordinate is a bit off, it's in the complete lower limit of the map because I can't get the height.
Maybe it's because my "flat" flag is on? I think I have it enabled, but I didn't see much difference anyway so I thought it wasn't really taking effect.
In Don's case, he's printing out the item_pos values before using them and they all seem to be integers.
Last edited by Ferk on Fri Sep 25, 2015 14:09, edited 1 time in total.
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
I don't recall if I was using mgv6 or mgv7.. but definitely not singlenode.Hybrid Dog wrote:you use mgv6, don't you?
I will try to check it further later when I reach home.
Re: Post your modding questions here
Ok, I just made a very simple mod called "heighmaptest" with only 5 lines in its init.lua:
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.
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)
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.
- paramat
- Developer
- Posts: 3700
- Joined: Sun Oct 28, 2012 00:05
- GitHub: paramat
- IRC: paramat
- Location: UK
Re: Post your modding questions here
Code: Select all
if minp.y > -5 and maxp.y < 200 then
Perhaps just ignore any heightmap value of y = 47 as that is usually inside a mountain (not in mgv6 though because of the above fact).
Who is online
Users browsing this forum: No registered users and 0 guests