Post your mapgen questions here (modding or engine)
-
minetestlover
- Member
- Posts: 68
- Joined: Sat Feb 18, 2023 13:31
Re: Post your mapgen questions here (modding or engine)
Wow, way more complicated than I imagined but I get it now. Thank you both!
- Midnight
- Member
- Posts: 222
- Joined: Sun Dec 19, 2021 13:56
- GitHub: Midnightx756
- IRC: Dragon
- In-game: Dragon_Abysss
- Location: Dehradun, India
Re: Post your mapgen questions here (modding or engine)
Hey could anyone tell me how to spawn a layer of water at a specified y coordinate, I wanna have it in my mod.
- Skamiz Kazzarch
- Member
- Posts: 694
- Joined: Fri Mar 09, 2018 20:34
- GitHub: Skamiz
- In-game: Skamiz
- Location: la lojbaugag.
Re: Post your mapgen questions here (modding or engine)
Just a singular layer?
I think the easiest way might be to register it as an ore with ore_type = "sheet".
Relevant API section: https://github.com/minetest/minetest/bl ... in=1#L9535
Don't give it any noise params, so the sheet is flat and use column_height_max = 1
I think the easiest way might be to register it as an ore with ore_type = "sheet".
Relevant API section: https://github.com/minetest/minetest/bl ... in=1#L9535
Don't give it any noise params, so the sheet is flat and use column_height_max = 1
- Midnight
- Member
- Posts: 222
- Joined: Sun Dec 19, 2021 13:56
- GitHub: Midnightx756
- IRC: Dragon
- In-game: Dragon_Abysss
- Location: Dehradun, India
Re: Post your mapgen questions here (modding or engine)
No actually somewhat a triple layer of fluid which only spawns in place of air deep undergroundSkamiz Kazzarch wrote: ↑Thu Jan 18, 2024 16:20Just a singular layer?
I think the easiest way might be to register it as an ore with ore_type = "sheet".
Relevant API section: https://github.com/minetest/minetest/bl ... in=1#L9535
Don't give it any noise params, so the sheet is flat and use column_height_max = 1
-
Dear_Roman
- Member
- Posts: 15
- Joined: Fri Mar 08, 2024 13:35
- In-game: Dear_Roman
- Location: Ru
Re: Post your mapgen questions here (modding or engine)
In order for the world to be generated neatly, I have to change the
mpgv7_np_mount_height.scale(to lower);
mpgv7_np.mountains.scale(to lower);
And mountains flag(off).
Otherwise the world looks unnatural. The problem appeared even before the appearance of the in-game download menu.
mpgv7_np_mount_height.scale(to lower);
mpgv7_np.mountains.scale(to lower);
And mountains flag(off).
Otherwise the world looks unnatural. The problem appeared even before the appearance of the in-game download menu.
Roman, 95, Ru.
-
Dear_Roman
- Member
- Posts: 15
- Joined: Fri Mar 08, 2024 13:35
- In-game: Dear_Roman
- Location: Ru
Re: Post your mapgen questions here (modding or engine)
Spawn/merge waterblock list to coord list(see worldedit srcs)
Upd: Oops...
if you are talking about setup water level then you should search water_max_lvl or noise, because the generator uses noise. Or create it (post Skamiz Kazzarch).
It is also worth paying attention to the presence of post events of the generator, where it is more profitable to do step-by-step replacements (if supported).
Roman, 95, Ru.
- Midnight
- Member
- Posts: 222
- Joined: Sun Dec 19, 2021 13:56
- GitHub: Midnightx756
- IRC: Dragon
- In-game: Dragon_Abysss
- Location: Dehradun, India
Re: Post your mapgen questions here (modding or engine)
I will post the master code on github soon, there you'll be free to editDear_Roman wrote: ↑Sun Mar 10, 2024 13:19Spawn/merge waterblock list to coord list(see worldedit srcs)
Upd: Oops...
if you are talking about setup water level then you should search water_max_lvl or noise, because the generator uses noise. Or create it (post Skamiz Kazzarch).
It is also worth paying attention to the presence of post events of the generator, where it is more profitable to do step-by-step replacements (if supported).
-
Dear_Roman
- Member
- Posts: 15
- Joined: Fri Mar 08, 2024 13:35
- In-game: Dear_Roman
- Location: Ru
Re: Post your mapgen questions here (modding or engine)
I think no. I am not satisfied with the direction of development that I have been observing lately. I would rather take on a separate fork with a(for) strict API. See viewtopic.php?p=434086#p434086 for more.
Roman, 95, Ru.
- Midnight
- Member
- Posts: 222
- Joined: Sun Dec 19, 2021 13:56
- GitHub: Midnightx756
- IRC: Dragon
- In-game: Dragon_Abysss
- Location: Dehradun, India
Re: Post your mapgen questions here (modding or engine)
Actually, I'm an Indian 12th grader and have to prepare for boards and competitive exams to get college acceptance and also these exams are damn hard than your country exams, that is why the development of my mod is not sustainable.Dear_Roman wrote: ↑Sun Mar 10, 2024 16:29I think no. I am not satisfied with the direction of development that I have been observing lately. I would rather take on a separate fork with a(for) strict API. See viewtopic.php?p=434086#p434086 for more.
-
Dear_Roman
- Member
- Posts: 15
- Joined: Fri Mar 08, 2024 13:35
- In-game: Dear_Roman
- Location: Ru
Re: Post your mapgen questions here (modding or engine)
Roman, 95, Ru.
-
minitechno
- Member
- Posts: 11
- Joined: Mon Jan 29, 2024 04:31
Re: Post your mapgen questions here (modding or engine)
Hi, I'm working on a game on Minetest engine. I'm trying to use Sokomine's lakes mod with my custom biomes mod I'm woking on. The lake mod contains a function to remove flora blocks from the ponds it generates. But it doesn't work well with my huge trees, even if I try to adjust the function parameters (e.g. keeps half the tree, like it's been sawn from top to bottom on it's whole lenght).
Is there a way to control the execution order of lua files? Changing their listing order in init.lua has no effect.
My logic is that if the lake mod lua file would execute before my biomes mod lua file, the problem wouldn't even exist, as my biomes mod don't place trees on water blocks. But maybe I'm incorrect, because I've seen in the forum that register_decoration will calculate the placement according to the block initially supposed to be there according to the terrain generation (and thus it may still think it's a dirt block even if the lakes mod replaced it with water?). Anyone has a better comprehension of this than me? I'm no programmer, just a Minetest passionate who likes to build custom biomes and has some basic programming notions.
Is there a way to control the execution order of lua files? Changing their listing order in init.lua has no effect.
My logic is that if the lake mod lua file would execute before my biomes mod lua file, the problem wouldn't even exist, as my biomes mod don't place trees on water blocks. But maybe I'm incorrect, because I've seen in the forum that register_decoration will calculate the placement according to the block initially supposed to be there according to the terrain generation (and thus it may still think it's a dirt block even if the lakes mod replaced it with water?). Anyone has a better comprehension of this than me? I'm no programmer, just a Minetest passionate who likes to build custom biomes and has some basic programming notions.
-
Sokomine
- Member
- Posts: 4317
- Joined: Sun Sep 09, 2012 17:31
- GitHub: Sokomine
- IRC: Sokomine
- In-game: Sokomine
Re: Post your mapgen questions here (modding or engine)
Most likely the upper part remains standing? That can happen with very big trees. Especially when they're higher than the mapchunk and continue in the next one.minitechno wrote: e.g. keeps half the tree, like it's been sawn from top to bottom on it's whole lenght
In a very limited way. If a mod depends or optionally depends on another mod, it ought to be executed *after* that optional mod at server startup. Which doesn't really help much here in this case.minitechno wrote: Is there a way to control the execution order of lua files?
That's right. Mapgen generates the mapchunk - which is usually a 80x80x80 nodes volume with an additional shell of 16 nodes around at each side. Mapgen then places the registered decorations for the biome. And after *that* mods that listen on register_on_generated can do their work. Thus, when my lakes mod gets to do its job on the mapchunk, the trees are already there.minitechno wrote: because I've seen in the forum that register_decoration will calculate the placement according to the block initially supposed to be there according to the terrain generation (and thus it may still think it's a dirt block even if the lakes mod replaced it with water?)
You could in theory use the moretrees approach - that is: not spawning the actual tree but just a special sapling that grows later. That'd be easier to remove but has its own drawbacks. Players moving around may find themshelves from time to time embedded in a tree that grew around them when they passed by.
I think I'm going to add a special node to the lakes mod that's placed if a tree grows out of the mapchunk. An lbm could munch up the remaining tree trunk from below when the above mapblock is loaded - and remove itself once it's done. Can't promise yet when I'll have time for that.
The lakes mod is sheduled for more work anyway. My mods that affect mapgen (mg_villages, lakes, ships_on_mapgen, basic_houses) ought to be able to work together. Right now they mostly can't.
I also intend to make the lakes a bit diffrent based on biome. Those in cold areas shall wear an ice crust. Trouble is that figuring out if whatever I get as biome information *does* warrant an ice crust isn't that easy. Perhaps it's related to me mostly working with mapgen v6, which does some things (biomes) diffrently than newer mapgens.
A list of my mods can be found here.
-
minitechno
- Member
- Posts: 11
- Joined: Mon Jan 29, 2024 04:31
Re: Post your mapgen questions here (modding or engine)
Thanks you for answering me about the execution order of lua files, I had searched a lot and didn't find anyting. Thanks also for all the work you put in your mods, studying their code helped me to learn a lot about modding.
I first noticed the issue of the top of the trees not being removed, but I was able to solve that by adjusting the height parameter in the function that removes flora from the ponds to match my highest trees. But now I have the issue of trees that are nearby the lake, and which half or even a quarter of the trunk is "in the lake" and gets removed by the function. Some of my trees have a 2x2, 3x3 or 4x4 trunk.
Another problem I run into is that some of my biomes have dense forests with a continuous tree canopy and some lakes get placed on the canopy. I understand why it happens (the function looks for the highest continuous surface), but don't have enough programming knowledge to fix that. That's another reason I was looking for a way to place the lakes on the terrain before the trees.
You could probably use minetest.get_biome_data(heat) to determine if there should be an ice crust (I understand you probably already know about that function, I don't want to insult you, just saying in case someone else can benefit from it). I live in Canada, where moving water (rivers) normally forms an ice crust, as well as non moving water (lakes) that are more than 0.5 meter deep. Shallower lakes/ponds normally freeze completely. Shallow creeks also freeze completely even if they're moving water. So I guess you'd have to take into account if it's MT river water or normal water if you want to go that far into realism.
I use different types of water (murky brown, clear aqua, almost black, etc.) according to the soil in each biome (I have soil blocks that are closer to real world than in MTG). I've been able to implement this in your mod using minetest.get_biome_data(biome) function and an if...elseif (probably there is a much better way to do it, but I'm no programmer and it's working so until I get better at programming it's staying).
For reference, I'm using mapgen V5 for my game, with tweaked Perlin noises, and with fixed x,y,z coordinates for the biomes (e.g. they are a 3D grid of biomes and yes, I've made sure to fit the size of the biomes so they're comprised of complete mapchunks). My game happens in an artificial space habitat which was created as a kind of zoo / natural reservation, so having biomes with clear cut straight line borders is not weird.
No, it's really like someone cut the trees from top to bottom, all along the lenght of the trunk.Most likely the upper part remains standing?
I first noticed the issue of the top of the trees not being removed, but I was able to solve that by adjusting the height parameter in the function that removes flora from the ponds to match my highest trees. But now I have the issue of trees that are nearby the lake, and which half or even a quarter of the trunk is "in the lake" and gets removed by the function. Some of my trees have a 2x2, 3x3 or 4x4 trunk.
Another problem I run into is that some of my biomes have dense forests with a continuous tree canopy and some lakes get placed on the canopy. I understand why it happens (the function looks for the highest continuous surface), but don't have enough programming knowledge to fix that. That's another reason I was looking for a way to place the lakes on the terrain before the trees.
I did successfully modify some stuff about your mod. One of my biomes has only ice, and another one has an ice crust on top of water. I was able to achieve the former, but not the later yet. For the ice crust on water, in the biome lua file I use node_water_top = my_custom_ice_block. So it would probably be easy for a programmer to add that crust when the biome is that one. But I still don't get how to manually place or replace blocks in a given volume (I did find the command and read it's documentation, I just don't understand the mathematics part of it I suppose, and even after looking at the code of many mods who do that, it seems too advanced for me currently).The lakes mod is sheduled for more work anyway.
You could probably use minetest.get_biome_data(heat) to determine if there should be an ice crust (I understand you probably already know about that function, I don't want to insult you, just saying in case someone else can benefit from it). I live in Canada, where moving water (rivers) normally forms an ice crust, as well as non moving water (lakes) that are more than 0.5 meter deep. Shallower lakes/ponds normally freeze completely. Shallow creeks also freeze completely even if they're moving water. So I guess you'd have to take into account if it's MT river water or normal water if you want to go that far into realism.
I use different types of water (murky brown, clear aqua, almost black, etc.) according to the soil in each biome (I have soil blocks that are closer to real world than in MTG). I've been able to implement this in your mod using minetest.get_biome_data(biome) function and an if...elseif (probably there is a much better way to do it, but I'm no programmer and it's working so until I get better at programming it's staying).
For reference, I'm using mapgen V5 for my game, with tweaked Perlin noises, and with fixed x,y,z coordinates for the biomes (e.g. they are a 3D grid of biomes and yes, I've made sure to fit the size of the biomes so they're comprised of complete mapchunks). My game happens in an artificial space habitat which was created as a kind of zoo / natural reservation, so having biomes with clear cut straight line borders is not weird.
Re: Post your mapgen questions here (modding or engine)
Hi so I got a loop that registers trees and it works great except it only registers tree decoration first run of loop. Other runs of the loop register nodes and send the debug messages but don't register the decoration.
Can multiple decorations use same schematic with different replacements? What did I do wrong?
If this is wrong section please let me know and I'll post in proper section
Can multiple decorations use same schematic with different replacements? What did I do wrong?
Code: Select all
if leafblock ~= "" and logblock ~= "" then
print(TreeName .. "registered as decoration 1")
minetest.register_decoration({
name = minetest.get_current_modname()..":"..TreeName .. "_Tree",
deco_type = "schematic",
place_on = plant_ground,
sidelen = 16,
fill_ratio = 0.0005,
y_max = 31000,
y_min = 1,
schematic = "/schematics/mctree.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
replacements = {["mcl_trees:leaves_oak"] = leafblock, ["mcl_trees:tree_oak"] = logblock,},
})
print(TreeName .. "registered as decoration 2")
end
- Attachments
-
- loadmcmods.zip
- (41.7 KiB) Downloaded 124 times
-
minitechno
- Member
- Posts: 11
- Joined: Mon Jan 29, 2024 04:31
Re: Post your mapgen questions here (modding or engine)
Hi, there seems to be a discussion about the same problem of schematics replacement working only the first time (with solutions) here : viewtopic.php?t=20334
Re: Post your mapgen questions here (modding or engine)
Cool! Thanks!minitechno wrote: ↑Sun May 26, 2024 14:19Hi, there seems to be a discussion about the same problem of schematics replacement working only the first time (with solutions) here : viewtopic.php?t=20334
I made a script to straight up duplicate the entire file for each, then use replacements.
-
minitechno
- Member
- Posts: 11
- Joined: Mon Jan 29, 2024 04:31
Re: Post your mapgen questions here (modding or engine)
I'm trying to register a decoration that I want to be only on the bottom of a rock block that protrudes from the terrain (I'm not good at English...), and only if there is a specific number of air nodes around it. So I'm needing to use spawn_by = "default:air" and "num_spawn_by = ". My problem is I can't figure out the number I need to put in num_spawn_by. I've found contradictory information in the documentation and in questions asked previously. I'm trying to understand on which Y level(s) (relative to the Y of the place_on node) register_decorations checks for spawn_by nodes.
I've tried inputting the number of the air nodes on the same Y as place_on node only. I've tried with Y and Y+1. I've tried with Y+1 and Y+2. Because that seemed to be the 3 possibilities described either in the documentation or the answered questions I could find. But none resulted in placement of a decoration, even with fill_ratio = 1 and terrain with plenty of rock blocks protruding the terrain.
On the picture, the node highlighted in yellow is my rock. The air node marked with a pink X is where I want to place my decoration (using place_offset_y = -2)

It works if I'm not fussy about the number of air nodes and I comment the code line about num_spawn_by, I do get the placement of the decoration.
My current code :
I've tried inputting the number of the air nodes on the same Y as place_on node only. I've tried with Y and Y+1. I've tried with Y+1 and Y+2. Because that seemed to be the 3 possibilities described either in the documentation or the answered questions I could find. But none resulted in placement of a decoration, even with fill_ratio = 1 and terrain with plenty of rock blocks protruding the terrain.
On the picture, the node highlighted in yellow is my rock. The air node marked with a pink X is where I want to place my decoration (using place_offset_y = -2)

It works if I'm not fussy about the number of air nodes and I comment the code line about num_spawn_by, I do get the placement of the decoration.
My current code :
Code: Select all
minetest.register_decoration({
decoration = {"my_mod:my_decoration_block"},
deco_type = "simple",
place_on = "my_mod:my_rock",
spawn_by = "default:air",
num_spawn_by = ???????
biomes = {"my_biome"},
fill_ratio = 1,
place_offset_y = -2,
y_min = 2,
y_max = 100,
})- Blockhead
- Moderator
- Posts: 2989
- Joined: Wed Jul 17, 2019 10:14
- GitHub: Montandalar
- IRC: Blockhead256
- In-game: Blockhead Blockhead256
- Location: Land Down Under
- Contact:
Re: Post your mapgen questions here (modding or engine)
It sounds like you are missing a part of the recipe: a check_offset. The spawn_by documentation says:minitechno wrote: ↑Thu Jun 20, 2024 21:11I'm trying to register a decoration that I want to be only on the bottom of a rock block that protrudes from the terrain (I'm not good at English...), and only if there is a specific number of air nodes around it. So I'm needing to use spawn_by = "default:air" and "num_spawn_by = ". My problem is I can't figure out the number I need to put in num_spawn_by. I've found contradictory information in the documentation and in questions asked previously. I'm trying to understand on which Y level(s) (relative to the Y of the place_on node) register_decorations checks for spawn_by nodes.
It always checks the nodes at the same height. With check_offset you can check above or below as well:lua_api.txt wrote:Code: Select all
spawn_by = "default:water", -- Node (or list of nodes) that the decoration only spawns next to. -- Checks the 8 neighboring nodes on the same height, -- and also the ones at the height plus the check_offset, excluding both center nodes.
By default when placing with spawn_by it also checks the nodes below. But you can instead check only the ones at the same level (=0) or above (=1). There is no provision for checking above and below at the same time.lua_api.txt wrote:Code: Select all
check_offset = -1, -- Specifies the offset that spawn_by should also check -- The default value of -1 is useful to e.g check for water next to the base node. -- 0 disables additional checks, valid values: {-1, 0, 1}
Why place_offset_y=-2? Would that not be the node below your marked pink X?minitechno wrote: ↑Thu Jun 20, 2024 21:11On the picture, the node highlighted in yellow is my rock. The air node marked with a pink X is where I want to place my decoration (using place_offset_y = -2)
So far, I am guessing that you are after a node that checks above and below for air, but can you clarify it - would the node marked with a black Xes qualify? I am guessing not, because the node above it has soil above it.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂
-
minitechno
- Member
- Posts: 11
- Joined: Mon Jan 29, 2024 04:31
Re: Post your mapgen questions here (modding or engine)
The node you marked with a black X wouldn't work, because register_decoration (as I'm understanding it) works only for "top nodes", the one that is the top of terrain in a given column. And the node you marked with the black X is not the top node, there is soil on top of it. So it would not be considered for placement by register_decoration.
I've looked into check_offset and tried to use it, without success, because I couldn't find out where spawn_by looks for the nearby block (which Y levels, it was contradicting answers that I found).
What I'm trying to do is to place a decoration where the pink X is, so I want to place a decoration block below the yellow outlined rock block. As I said, if I'm not fussy with the number of air blocks surrounding the rock block, using an -2 offset it works, it places the decoration below the rock block.
But I really would like to place the decoration only in specific conditions, which are when there is at least a row of 3 of these protruding rock blocks and place it under blocks which are not the ones at the end of these rows. Which I figured out is possible to determine by the number of air blocks surrounding the rock block (will always be the same number of air blocks for the blocks in a row that are not at the ends of the row). I just need to know the number of air blocks either on the same Y level as the rock block, or under it, or above it. That's because I use specific terrain generation that produces these kind of rock protuberances and so I can count the number of air blocks on any of the 3 Y levels mentionned, it doesn't matter. The only other place where a same number of air blocks could occur in the same biome (so not below ocean level) is in cavern entrances, which I'm ok with having the same decorations there.
I know programmers would be able to do some nice script to determine that by maths, but I'm no programmer. I've seen abdecor waterfalls for example, who has a nice script that finds out rock walls and place water sources, which is kind of similar to what I'm trying to do, I always browse existing mods to try to understand their code and use/adapt parts of it. But that was way too complicated, I couldn't understand at all that code. So I try to take advantage of absolutely all mechanics already in the game functions as I can. And it seems like register_decoration could do what I'm looking for if only I can figure out how exactly spawn_by, num_spawn_by and probably also check_offset work.
I have several other decorations I'd like to place in the biomes of my game that would require to understand this mechanic, so I feel like I should try to figure it out.
I will try to do some tests using your information : By default when placing with spawn_by it also checks the nodes below. But you can instead check only the ones at the same level (=0) or above (=1). There is no provision for checking above and below at the same time.
I've looked into check_offset and tried to use it, without success, because I couldn't find out where spawn_by looks for the nearby block (which Y levels, it was contradicting answers that I found).
What I'm trying to do is to place a decoration where the pink X is, so I want to place a decoration block below the yellow outlined rock block. As I said, if I'm not fussy with the number of air blocks surrounding the rock block, using an -2 offset it works, it places the decoration below the rock block.
But I really would like to place the decoration only in specific conditions, which are when there is at least a row of 3 of these protruding rock blocks and place it under blocks which are not the ones at the end of these rows. Which I figured out is possible to determine by the number of air blocks surrounding the rock block (will always be the same number of air blocks for the blocks in a row that are not at the ends of the row). I just need to know the number of air blocks either on the same Y level as the rock block, or under it, or above it. That's because I use specific terrain generation that produces these kind of rock protuberances and so I can count the number of air blocks on any of the 3 Y levels mentionned, it doesn't matter. The only other place where a same number of air blocks could occur in the same biome (so not below ocean level) is in cavern entrances, which I'm ok with having the same decorations there.
I know programmers would be able to do some nice script to determine that by maths, but I'm no programmer. I've seen abdecor waterfalls for example, who has a nice script that finds out rock walls and place water sources, which is kind of similar to what I'm trying to do, I always browse existing mods to try to understand their code and use/adapt parts of it. But that was way too complicated, I couldn't understand at all that code. So I try to take advantage of absolutely all mechanics already in the game functions as I can. And it seems like register_decoration could do what I'm looking for if only I can figure out how exactly spawn_by, num_spawn_by and probably also check_offset work.
I have several other decorations I'd like to place in the biomes of my game that would require to understand this mechanic, so I feel like I should try to figure it out.
I will try to do some tests using your information : By default when placing with spawn_by it also checks the nodes below. But you can instead check only the ones at the same level (=0) or above (=1). There is no provision for checking above and below at the same time.
Blockhead wrote: ↑Fri Jun 21, 2024 04:15It sounds like you are missing a part of the recipe: a check_offset. The spawn_by documentation says:minitechno wrote: ↑Thu Jun 20, 2024 21:11I'm trying to register a decoration that I want to be only on the bottom of a rock block that protrudes from the terrain (I'm not good at English...), and only if there is a specific number of air nodes around it. So I'm needing to use spawn_by = "default:air" and "num_spawn_by = ". My problem is I can't figure out the number I need to put in num_spawn_by. I've found contradictory information in the documentation and in questions asked previously. I'm trying to understand on which Y level(s) (relative to the Y of the place_on node) register_decorations checks for spawn_by nodes.It always checks the nodes at the same height. With check_offset you can check above or below as well:lua_api.txt wrote:Code: Select all
spawn_by = "default:water", -- Node (or list of nodes) that the decoration only spawns next to. -- Checks the 8 neighboring nodes on the same height, -- and also the ones at the height plus the check_offset, excluding both center nodes.By default when placing with spawn_by it also checks the nodes below. But you can instead check only the ones at the same level (=0) or above (=1). There is no provision for checking above and below at the same time.lua_api.txt wrote:Code: Select all
check_offset = -1, -- Specifies the offset that spawn_by should also check -- The default value of -1 is useful to e.g check for water next to the base node. -- 0 disables additional checks, valid values: {-1, 0, 1}
Why place_offset_y=-2? Would that not be the node below your marked pink X?minitechno wrote: ↑Thu Jun 20, 2024 21:11On the picture, the node highlighted in yellow is my rock. The air node marked with a pink X is where I want to place my decoration (using place_offset_y = -2)
So far, I am guessing that you are after a node that checks above and below for air, but can you clarify it - would the node marked with a black Xes qualify? I am guessing not, because the node above it has soil above it.
436826_underhang.jpeg
-
minitechno
- Member
- Posts: 11
- Joined: Mon Jan 29, 2024 04:31
Re: Post your mapgen questions here (modding or engine)
Now I'm totally lost. I'll try to explain and illustrate better and simplify the problem by not caring about the Y level below the place_on block for now.
I'm trying to place a red block below a rock block in a specific biome, if that rock block is at the edge of the terrain and is not a corner block. If the rock block is in that position (e.g. the block highlighted in yellow on the picture), it has 3 air blocks on it's 8 neighboors on the same Y level (the 3 pink X on my picture).
As you can see on the screenshot, it still doesn't place the decoration. And I really don't understand why. I know I'm probably just incredibly dumb. But I'd really like to learn how to use register_decoration to it's full potential. The yellow outlined block is at Y=29.

My code is currently :
I'm trying to place a red block below a rock block in a specific biome, if that rock block is at the edge of the terrain and is not a corner block. If the rock block is in that position (e.g. the block highlighted in yellow on the picture), it has 3 air blocks on it's 8 neighboors on the same Y level (the 3 pink X on my picture).
As you can see on the screenshot, it still doesn't place the decoration. And I really don't understand why. I know I'm probably just incredibly dumb. But I'd really like to learn how to use register_decoration to it's full potential. The yellow outlined block is at Y=29.

My code is currently :
Code: Select all
minetest.register_decoration({
decoration = "mygame:myredrock",
deco_type = "simple",
place_on = "mygame:mypastelgreenrock",
spawn_by = "default:air",
num_spawn_by = 3,
check_offset = 0, -- to simplify, let's check only on the same Y level
biomes = {"a1"}, -- my game-specific biome you see on screenshot
fill_ratio = 1,
place_offset_y = -2,
y_min = 2,
y_max = 31000,
})- Blockhead
- Moderator
- Posts: 2989
- Joined: Wed Jul 17, 2019 10:14
- GitHub: Montandalar
- IRC: Blockhead256
- In-game: Blockhead Blockhead256
- Location: Land Down Under
- Contact:
Re: Post your mapgen questions here (modding or engine)
I haven't tried it in my own game, but I can't see how that wouldn't work other than if the decoration is an attached node and it's actually trying to spawn in the node below the red node (isn't that what -2 means after all? or is it relative to the node above?) - I would have thought it would do something like fall off after placement anyway... Maybe it's something ancillary like the biome. Hard to tell.minitechno wrote: ↑Sat Jun 22, 2024 22:13Now I'm totally lost. I'll try to explain and illustrate better and simplify the problem by not caring about the Y level below the place_on block for now.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂
Re: Post your mapgen questions here (modding or engine)
@minitechno - Try using the flags = "all_ceilings" flag and using the place_offset_y = -1 to place your red nodes on ceilings and hangings of the blocks found.
-
minitechno
- Member
- Posts: 11
- Joined: Mon Jan 29, 2024 04:31
Re: Post your mapgen questions here (modding or engine)
OK, so after several tests using info given by @Blockhead and @TenPlus1 and still going nowhere, I opted for a new test. I generate 3 layers of "decorations" 30 blocks above my terrain.
So if you look at my current code below for the decoration placement, I ask it to place a yellow rock block near a red block. There are no red rock whatsoever in this area of the map, it spawns in a different biome. Currently, the yellow block gets placed below any aqua green block that has nothing on top of it. I'm getting more and more confused about how register_decoration works.
So if you look at my current code below for the decoration placement, I ask it to place a yellow rock block near a red block. There are no red rock whatsoever in this area of the map, it spawns in a different biome. Currently, the yellow block gets placed below any aqua green block that has nothing on top of it. I'm getting more and more confused about how register_decoration works.
Code: Select all
minetest.register_decoration({
decoration = {"mymod_principal:r_marbrejaune"},-- the yellow rock
deco_type = "simple",
place_on = "mymod_principal:r_marbrevert", -- the aqua green rock
spawn_by="mymod_principal:r_rubis", -- a red rock, very easy to spot
--num_spawnby = 3,
check_offset = -1,
biomes = {"a1"},-- the current biome on screenshot
fill_ratio = 10,
place_offset_y = -2,
flags = "force_placement,all_floors", --I tried using all_ceilings, with or without force_placement, it still doesn't place the decoration as expected according to documentation and answers I got from this discussion
y_min = 2,
y_max = 31000,
})minitechno wrote: ↑Sat Jun 22, 2024 22:13Now I'm totally lost. I'll try to explain and illustrate better and simplify the problem by not caring about the Y level below the place_on block for now.
I'm trying to place a red block below a rock block in a specific biome, if that rock block is at the edge of the terrain and is not a corner block. If the rock block is in that position (e.g. the block highlighted in yellow on the picture), it has 3 air blocks on it's 8 neighboors on the same Y level (the 3 pink X on my picture).
As you can see on the screenshot, it still doesn't place the decoration. And I really don't understand why. I know I'm probably just incredibly dumb. But I'd really like to learn how to use register_decoration to it's full potential. The yellow outlined block is at Y=29.
My code is currently :Code: Select all
minetest.register_decoration({ decoration = "mygame:myredrock", deco_type = "simple", place_on = "mygame:mypastelgreenrock", spawn_by = "default:air", num_spawn_by = 3, check_offset = 0, -- to simplify, let's check only on the same Y level biomes = {"a1"}, -- my game-specific biome you see on screenshot fill_ratio = 1, place_offset_y = -2, y_min = 2, y_max = 31000, })
- Deadlock
- Member
- Posts: 82
- Joined: Mon Aug 28, 2017 06:47
- GitHub: Distributed-DeadLock
- In-game: Jimmey
biomemap mostly filled with zeros
When i retrieve a biomemap in the on_generated() callback function,
the array is mostly filled with zeros.
I only seem to get useful values in a mapchunk that is on the surface layer.
Why is that? And how can i get the biome-data for all the nodes in my chunk?
My test code:
with mod.conf:
the array is mostly filled with zeros.
I only seem to get useful values in a mapchunk that is on the surface layer.
Why is that? And how can i get the biome-data for all the nodes in my chunk?
My test code:
Code: Select all
local function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
print(dump(core.registered_biomes))
minetest.register_on_generated(function(minp, maxp, seed)
-- get the biomemap object for the chunk
local bmap = core.get_mapgen_object("biomemap")
print(dump(bmap))
end)Code: Select all
name = test
title = Just a Test
author = Distributed-DeadLock
depends = default-
repetitivestrain
- Member
- Posts: 140
- Joined: Fri Aug 09, 2024 01:54
Re: Post your mapgen questions here (modding or engine)
It would be a great convenience to me if Lua map generators were permitted to specify that map generation must take place along mapblock coordinates aligned to MapChunks on the Y axis and additionally a distinct vertical chunk size from those applied to horizontal generation. My map generator is quite expensive and requires that 384 nodes between -128 and 256 be evaluated for each horizontal position if only to produce a height map that informs subsequent surface and structure generation, whatever may be the height of the area being generated, and under the current system the output from this process otherwise largely goes to waste. And inasmuch as all of the map generator is implemented in Lua for absolute fidelity to another voxel block game, this wastage is not acceptable as ~500 ms are required to emerge a single 80x384x80 area, and repeating the process for every vertical MapChunk at least quadruples this figure.
Caching is not an option because map generation does not appear to be aligned to MapChunk boundaries on any of the three axes, and more sophisticated caching strategies prompt the jit to create inefficient loops with innumerable side traces that are linked to the unrolled loop prologue rather than its optimized body (assuming it does not hit a register coalescing limit and decline to compile any side traces at all).
Would anyone care to submit this feature request to the powers that be? I am not interested in registering for a Microsoft-operated issue tracker. It would be appreciated.
Caching is not an option because map generation does not appear to be aligned to MapChunk boundaries on any of the three axes, and more sophisticated caching strategies prompt the jit to create inefficient loops with innumerable side traces that are linked to the unrolled loop prologue rather than its optimized body (assuming it does not hit a register coalescing limit and decline to compile any side traces at all).
Would anyone care to submit this feature request to the powers that be? I am not interested in registering for a Microsoft-operated issue tracker. It would be appreciated.
cdb_6dcb4b04312d
Who is online
Users browsing this forum: No registered users and 0 guests