Page 11 of 34

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Mar 11, 2017 14:26
by Wuzzy
OK, thanks paramat. Antother question which goes directly to you:

I know you have made a lot of work on the Minetest Game biomes for 0.4.15. How did you manage that these biome are relatively well-balanced out in terms of size? Do you maybe have a tool or a trick or something?

I understand that the heat and humity points are very important and are used in a Voronoi diagram. But I feel it is very tedious (and especially unreliable) to just blindly adjust these points and restart Minetest 1,000,000 times, hope for the best and waste a lot of time to fly over the world just to see if it worked. Whenever I try to set the biome sizes for my own biomes, the biomes are either too large or too small or don't appear at all. :-/

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Mar 11, 2017 18:33
by TumeniNodes
burli wrote:If you want a different texture you need to make a new node and use this in the schematic
Really? (exasperated sigh) I didn't realize fallen logs were part of the schematic, though I guess it makes sense to me now.

I did create a new node for each (I simply made, i.e., default tree use only the tree texture, and then added a new node real quick called "whichever"_tree_top, and kept that one with the original texture layout.)

Thank you burli. Guess it can wait until I finally do get around to messing with schematics or the method you have been using : )
This is just for my subgame anyway

btw, I apologize for completely misreading your "ridges" issue... I had thought you wanted steeper sides, by lowering the seabed :P Hope you got you issue resolved

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Mar 11, 2017 18:54
by burli
Sadly the depth of the ridges is hard coded. Can't change it with a noise

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Mar 12, 2017 06:29
by FaceDeer
I've begun tinkering with my own version of a caverealms mod, with the goal of building a generalized mapgen library for creating large underground caverns and populating them with various biome-specific flora and features. I'd like to first echo Wuzzy's question above about the best way to go about balancing the area covered by various biomes. It's especially tricky to do it underground.

Edit: I just found this post by Paramat about how to use GeoGebra to work with Voronoi diagrams and it looks fantastic, this may solve that part of things. The second point below remains, though.

Second, I've discovered that the default mod adds an "underground" biome that seems to be seriously cramping my style. It stretches over the entire underground y-value range. Is there a way to override an already-registered biome so I can get it out of the way of my own underground biomes without disturbing the other biomes registered by default?

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Mar 12, 2017 06:55
by burli
You can clear all registered biomes with minetest.clear_registered_biomes() and define your own

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Mar 12, 2017 07:32
by FaceDeer
burli wrote:You can clear all registered biomes with minetest.clear_registered_biomes() and define your own
I'd like to leave the rest of the biomes intact, though. I want my mod to be able to act as an add-on to default (and not be bound to it if someone wants to use the mod with something other than default) rather than be a wholesale replacement of it. There are ways to override various other registered things (nodes, crafting recipes, etc) so I was hoping there'd be something similar for biomes.

I suppose I could copy-and-paste the default mod's biome registration into my mod and do the wipe-and-replace thing when the default mod is loaded, but that's pretty hacky and I'll need to update the copy-and-pasted biomes any time default gets an update.

Might simply re-registering a new biome with the same name as the old one override it? Biomes don't appear to have name restrictions on them.

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Mar 12, 2017 07:39
by burli
I think it should be possible to make a copy of minetest.registered_biomes, modify it an register again. The table looks like this. Or probably just overwrite what you want to change

Code: Select all

{
	coniferous_forest_ocean = {
		node_riverbed = "default:sand",
		node_top = "default:sand",
		node_filler = "default:sand",
		depth_top = 1,
		humidity_point = 70,
		y_max = 4,
		y_min = -112,
		heat_point = 45,
		depth_riverbed = 2,
		name = "coniferous_forest_ocean",
		depth_filler = 3
	},
	tundra = {
		node_riverbed = "default:gravel",
		node_dust = "default:snowblock",
		humidity_point = 40,
		y_min = 2,
		heat_point = 0,
		depth_riverbed = 2,
		name = "tundra",
		y_max = 31000
	},
	underground = {
		humidity_point = 50,
		y_max = -113,
		heat_point = 50,
		name = "underground",
		y_min = -31000
	},
	grassland = {
		node_riverbed = "default:sand",
		node_top = "default:dirt_with_grass",
		node_filler = "default:dirt",
		depth_top = 1,
		humidity_point = 35,
		y_max = 31000,
		y_min = 6,
		heat_point = 50,
		depth_riverbed = 2,
		name = "grassland",
		depth_filler = 1
	},
}

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Mar 12, 2017 09:02
by FaceDeer
Well, this is baffling. I tried as you suggest, using this code to do a thorough deep copy:

Code: Select all

minetest.debug(dump(minetest.registered_biomes))
local replace_underground = function()
	local registered_biomes_copy = {}
	for old_biome_key, old_biome_def in pairs(minetest.registered_biomes) do
		minetest.debug("copying biome", old_biome_key)
		local copied_biome_def = {}
		for biomekey, biomevalue in pairs(old_biome_def) do
			copied_biome_def[biomekey] = biomevalue
		end
		registered_biomes_copy[old_biome_key] = copied_biome_def
	end
	if registered_biomes_copy.underground ~= nil then
		minetest.debug("replacing underground")
		registered_biomes_copy.underground = {
			name = "underground",
			y_min = -700,
			y_max = -113,
			heat_point = 50,
			humidity_point = 50,
		}
	end
	minetest.clear_registered_biomes()
	for _, new_biome_def in pairs(registered_biomes_copy) do
		minetest.debug("re-registering biome", new_biome_def.name)
		minetest.register_biome(new_biome_def)
	end
end
replace_underground()
minetest.debug(dump(minetest.registered_biomes))
And the before-and-after dumps of minetest.registered_biomes matched exactly, aside from the desired change to the underground biome. But when I regenerated the land I was on up on the surface the aspen forest I was in was suddenly mixed with new jungle trees that shouldn't have been there.

I have no idea how jungle trees are getting added. The biome's boundary is the same, and the neighboring savannah isn't affected. I'll do some more poking tomorrow and see if I can figure this out.

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Mar 12, 2017 13:51
by Wuzzy
Thanks, FaceDeer, for digging out the paramat post. This was important, now I think I can finally reasonably work with proper biomes. :-)

Jungle trees are simply added as a decoration in the biomes “rainforest” and “rainforest_swamp” in the mapgens v5, v7, valleys, flat and fractal. Look for “default.register_decorations()”. Note that in v6, biomes are hardcoded in Minetest, not added by Lua. Jungle trees in v6 are triggered by the v6 mapgen flags.

See also: http://wiki.minetest.net/Map_generator_features

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Mar 12, 2017 17:28
by FaceDeer
Okay, I got my biome-override code working properly. The key turned out to be wiping and re-registering all the decorations as well as the biomes. I haven't looked at the Minetest source code behind all this but I have a guess as to what's going on. Internally biome names aren't used by the mapgen, there appears to be some sort of biome ID number that gets assigned to biomes when they're registered (this is what's returned in the biome mapgen object). I suspect that when a decoration is registered the biomes it belongs to is stored as that biome ID number rather than the biome's name. Then when I wipe the biomes and re-register them some of them wind up being assigned different biome ID numbers, and the decorations don't get updated. So some decorations wind up assigned to a different biome than they had when they were first registered and that's why jungle trees were appearing in the wrong biome for me.

For the benefit of future modders who may stumble across this, here's the code I've come up with to replace the underground biome with a modified version:

Code: Select all

local replace_underground = function()
	local registered_biomes_copy = {}
	for old_biome_key, old_biome_def in pairs(minetest.registered_biomes) do
		registered_biomes_copy[old_biome_key] = old_biome_def
	end
	local registered_decorations_copy = {}
	for old_decoration_key, old_decoration_def in pairs(minetest.registered_decorations) do
		registered_decorations_copy[old_decoration_key] = old_decoration_def
	end
	if registered_biomes_copy.underground ~= nil then
		registered_biomes_copy.underground = {
			name = "underground",
			y_min = -700,
			y_max = -113,
			heat_point = 50,
			humidity_point = 50,
		}
	end
	minetest.clear_registered_decorations()
	minetest.clear_registered_biomes()
	for biome_key, new_biome_def in pairs(registered_biomes_copy) do
		minetest.register_biome(new_biome_def)
	end
	for decoration_key, new_decoration_def in pairs(registered_decorations_copy) do
		minetest.register_decoration(new_decoration_def)
	end
end
replace_underground()
(Turns out the deep-copying I was doing in the earlier version was unnecessary, I just wanted to cover my bases).

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Mar 12, 2017 17:42
by burli
Good to know that. Have to keep it in mind

Re: Post your mapgen questions here (modding or engine)

Posted: Tue Mar 14, 2017 01:44
by paramat
burli wrote:Is it possible to use biomes to generate different stone underground? I tried it, but it didn't work. Maybe I did something wrong?
Yes it's possible, just define 'node stone'. But the y limits of the biome need to be > 80 nodes apart or either side of a mapchunk border because the biome for the entire node column is only calculated once at column top, then stays in effect for the whole node column.

Re: Post your mapgen questions here (modding or engine)

Posted: Tue Mar 14, 2017 01:55
by paramat
FaceDeer wrote:Second, I've discovered that the default mod adds an "underground" biome that seems to be seriously cramping my style. It stretches over the entire underground y-value range. Is there a way to override an already-registered biome so I can get it out of the way of my own underground biomes without disturbing the other biomes registered by default?
No, all you can do is use a mod to clear all biomes then re-register the complete set but with your changes. It has been described as hacky but this is actually the official way to alter biomes, most mods and subgames would want to completely change all biomes anyway.
To avoid the engine side of mapgen becoming overcomplex the approach is to require mods to do slightly more complex stuff in Lua.

Re: Post your mapgen questions here (modding or engine)

Posted: Tue Mar 14, 2017 02:02
by paramat
To balance biome areas you want to very roughly equalise the areas of the voronoi cells, however the more extreme values are less common so cell area needs to rise towards the edges and corners of the diagram.

This is our current system (the 'underground' biome is at (50, 50)):

Image

Horizontal - Temperature
Vertical - Humidity

ICE Icesheet
TAI Taiga
COF Coniferous forest
DEF Deciduous forest
RAF Rainforest

TUN Tundra
SGR Snowy grassland
GRA Grassland
SAV Savanna

CDE Cold desert
SDE Sandstone desert
DES Desert

Re: Post your mapgen questions here (modding or engine)

Posted: Fri Mar 17, 2017 17:00
by Wuzzy
I want to place a simple 1-node decoration on the floor, namely a carved pumpkin. This is a node which can be rotated (it uses facedir). How can I use the decorations API to randomly rotate a simple decoration?


PS: I just added the biome question to the modding FAQ:
http://dev.minetest.net/Modding_FAQ#Advanced_modding

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Mar 18, 2017 15:16
by paramat
Looks like simple decorations cannot be randomly rotated. You can create a 1-node schematic decoration and use the random rotation flag. Define the schematic as a lua table (you won't need the 'place centre' flags:

Code: Select all

	minetest.register_decoration({
		deco_type = "schematic",
		place_on = {"default:dirt_with_grass"},
		sidelen = 16,
		noise_params = {
			offset = 0.0,
			scale = -0.0008,
			spread = {x = 250, y = 250, z = 250},
			seed = 2,
			octaves = 3,
			persist = 0.66
		},
		biomes = {"deciduous_forest"},
		y_min = 1,
		y_max = 31000,
		schematic = {
			size = {x = 3, y = 3, z = 1},
			data = {
				{name = "air", prob = 0},
				{name = "air", prob = 0},
				{name = "air", prob = 0},
				{name = "default:aspen_tree", param2 = 12},
				{name = "default:aspen_tree", param2 = 12},
				{name = "default:aspen_tree", param2 = 12, prob = 127},
				{name = "flowers:mushroom_red", prob = 63},
				{name = "flowers:mushroom_brown", prob = 63},
				{name = "air", prob = 0},
			},
		},
		flags = "place_center_x",
		rotation = "random",
})

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Mar 18, 2017 15:20
by paramat
Typos in your Wiki addition:
'align the Vonoroi cells, making balanncing a lot easier.'
Should be 'Voronoi' and 1 'n' in 'balancing'.

Re: Post your mapgen questions here (modding or engine)

Posted: Mon Mar 20, 2017 23:06
by Wuzzy
OK, thanks. I will look into this. Also, wiki is fixed.

Paramat, you really should get a wiki account. I think Calinou is the one to ask. It is absolutely unacceptable that core developers are not allowed to edit the wiki (not your fault, of course).

What is on_mapgen_init and why isn't it documented in lua_api.txt?

Why does this code not remove dungeons?:

Code: Select all

minetest.register_on_mapgen_init(function()
         minetest.set_mapgen_setting("mg_flags", "nodungeons")
end) 
Or this code? (Called on “top Lua level”, not inside of any function, in a brand new world)

Code: Select all

minetest.set_mapgen_setting("mg_flags", "nodungeons")
I have checked map_meta.txt. Mg_flags is untouched. There is only one place in the subgame + all active mods where minetest.set_mapgen_setting is called. No over mod tampers with the mapgen settings. Weird. Tested in 0.4.15. Bug or user failure? ;-)


Why does your previous decoration example have so many air? It looks like there is an entire row which is completely unused (probability of 0). Why has the schematic a height of 3 when it only needs 2?

Why doesn't this schematic decoration spawn any grass?:

Code: Select all

	minetest.register_decoration({
		deco_type = "schematic",
		schematic = {
			size = { x=1, y=1, z=1 },
			data = {
				{ name = "default:grass_5", param1=255, },
			},
		},
		place_on = {"default:dirt_with_grass"},
		sidelen = 8,
		noise_params = {
			offset = -0.01,
			scale = 0.03,
			spread = {x = 500, y = 500, z = 500},
			seed = 420,
			octaves = 2,
			persist = 0.6,
		},
		y_min = 1,
		y_max = 40,
		flags = "",
	})
But this one does?:

Code: Select all

	minetest.register_decoration({
		deco_type = "schematic",
		schematic = {
			size = { x=1, y=2, z=1 },
			data = {
				{ name = "air", prob = 0 },
				{ name = "default:grass_5", param1=255, },
			},
		},
		place_on = {"default:dirt_with_grass"},
		sidelen = 8,
		noise_params = {
			offset = -0.01,
			scale = 0.03,
			spread = {x = 500, y = 500, z = 500},
			seed = 420,
			octaves = 2,
			persist = 0.6,
		},
		y_min = 1,
		y_max = 40,
		flags = "",
	})


EDIT: Final decoration question (in this post): Why is this even possible?:
Image
https://i.imgur.com/LAqTiKz.png

The purple flowered plant is a peony. It is supposed to be made out of 2 nodes at all times, a top part and a bottom part (like a door). It must never be seperated.
The peony to the right is the expected plant.
But the mapgen generated this “half peony” in the middle, on jungle wood. Which is wrong. It also happened to me that the top part of the peony spawned on fern (=jungle grass in Minetest Game) or tall grass (=grass in Minetest Game). Note that most peonies generated by the mapgen are correct, the seperation happens rarely.

Why did this happen and how can I prevent this?

Decorations code:

Code: Select all

	-- Large flowers
	local register_large_flower = function(name, seed, offset)
		minetest.register_decoration({
			deco_type = "schematic",
			schematic = {
				size = { x=1, y=3, z=1 },
				data = {
					{ name = "air", prob = 0 },
					{ name = "mcl_flowers:"..name, param1=255, },
					{ name = "mcl_flowers:"..name.."_top", param1=255, },
				},
			},
			place_on = {"mcl_core:dirt_with_grass"},

			sidelen = 16,
			noise_params = {
				offset = offset,
				scale = 0.01,
				spread = {x = 300, y = 300, z = 300},
				seed = seed,
				octaves = 5,
				persist = 0.62,
			},
			y_min = 1,
			y_max = 30,
			flags = "",
		})
	end

	register_large_flower("rose_bush", 9350, -0.008)
	register_large_flower("peony", 10450, -0.008)
	register_large_flower("lilac", 10600, -0.007)
	register_large_flower("sunflower", 2940, -0.005)
Mapgen used: v6. You see a v6 jungle here.


EDIT 2: Hooray! The schematic rotation trick suggested by you previously worked! Thanks a bunch! :-)

Re: Post your mapgen questions here (modding or engine)

Posted: Tue Mar 21, 2017 00:41
by paramat
> What is on_mapgen_init and why isn't it documented in lua_api.txt?

It's deprecated now and not needed around minetest.set_mapgen_setting().

> Why does this code not remove dungeons?:

Try:
minetest.set_mapgen_setting(name, value, [override_meta])
With true as the 3rd argument. Even in a new world map meta may need overriding.
When setting mg_flags include all arguments:
"caves,nodungeons,light,decorations"
otherwise the other flags may be set to off.

> Why does your previous decoration example have so many air? It looks like there is an entire row which is completely unused (probability of 0). Why has the schematic a height of 3 when it only needs 2?

Log decorations have the lowest level being unplaced nodes (air prob = 0) because schematics are always placed with their lowest level of nodes in the ground instead of on the ground, so a layer of non-placed nodes is needed so that the log is above ground. Air prob = 0 is the official way to specify a node that will not replace existing nodes.

> Why doesn't this schematic decoration spawn any grass?:

For the same reason, the grass is placed in the ground, also you are using
{ name = "default:grass_5", param1=255, },
that should be prob = 255, param1 will not be recognised in a lua table schem so the grass was probably not replacing the ground node it was in.

> But the mapgen generated this “half peony” in the middle, on jungle wood. Which is wrong.

Your jungletree was placed first but doesn't have root nodes in the ground, so the ground node under the peony is still dirt or grass, when the peony is placed later it simply looks at the node at ground level and therefore places a peony at that point. Because the peony is not force-placed only the top peony node appears where air is.
If your jungletree has root nodes in the ground this will stop other decorations being placed at the same position.
This is why mapgen trees in MTG have root nodes.

Ah mgv6, i guess mgv6 jungletrees do not replace the dirt or grass at ground level, that's why.

> It also happened to me that the top part of the peony spawned on fern (=jungle grass in Minetest Game) or tall grass (=grass in Minetest Game)

Order of decoration registrations determines order of placement. See default/mapgen.lua, the taller decorations are placed first to avoid them being placed 'around' smaller decorations. Register your peony before 1-node decorations like grasses.

Re: Post your mapgen questions here (modding or engine)

Posted: Tue Mar 21, 2017 02:16
by Wuzzy
> Why does this code not remove dungeons?:

Try:
minetest.set_mapgen_setting(name, value, [override_meta])
With true as the 3rd argument. Even in a new world map meta may need overriding.
When setting mg_flags include all arguments:
"caves,nodungeons,light,decorations"
otherwise the other flags may be set to off.
OK, it works.
Is it possible to change the default mapgen flags for a subgame, so the user can still overwrite them?
I noticed when I do this, the user-supplied mg_flags has no longer an effect, so using minetest.set_mapgen_setting appears to bascially hardcode the mg_flags with no way for the user to change it. :-/
> But the mapgen generated this “half peony” in the middle, on jungle wood. Which is wrong.

Your jungletree was placed first but doesn't have root nodes in the ground, so the ground node under the peony is still dirt or grass, when the peony is placed later it simply looks at the node at ground level and therefore places a peony at that point. Because the peony is not force-placed only the top peony node appears where air is.
If your jungletree has root nodes in the ground this will stop other decorations being placed at the same position.
This is why mapgen trees in MTG have root nodes.

Ah mgv6, i guess mgv6 jungletrees do not replace the dirt or grass at ground level, that's why.

> It also happened to me that the top part of the peony spawned on fern (=jungle grass in Minetest Game) or tall grass (=grass in Minetest Game)

Order of decoration registrations determines order of placement. See default/mapgen.lua, the taller decorations are placed first to avoid them being placed 'around' smaller decorations. Register your peony before 1-node decorations like grasses.
Is it possible to prevent this?
I rather want the peony to not be generated at all instead of being generated only partially, because this is something which must never happen in my mapgen. I think of this: If Minetest fails to place any node (except those with probability 0), the entire decoration is not placed. Think of it as an “all-or-nothing decoration”. :D
Is this possible?

Your advice to generate large decorations first seems to work.
But I still have large plants over ferns (=jungle grass), maybe because it also comes from v6. This almost sounds like a bug to me and I guess I file an issue.

Re: Post your mapgen questions here (modding or engine)

Posted: Tue Mar 21, 2017 16:39
by paramat
> Is it possible to change the default mapgen flags for a subgame, so the user can still overwrite them?

I doubt it.

> I think of this: If Minetest fails to place any node (except those with probability 0), the entire decoration is not placed. Think of it as an “all-or-nothing decoration”. :D
Is this possible?

Possible but complex and slow, it would have to be optional because with trees we want them to intersect and overlap, decoration code has of course to be lightweight and fast because it acts during mapgen. So no doing this is not liely to happen.
As explained you can already avoid this using order of registration.

> But I still have large plants over ferns (=jungle grass), maybe because it also comes from v6

This is because the mgv6 1-node decorations are registered in default/mapgen.lua before your mod decorations so you have the order of placement wrong. It's not a bg.
You need to 'minetest.clear_registered_decorations' then re-register all (including mgv6 decorations) in a new order.

Re: Post your mapgen questions here (modding or engine)

Posted: Fri Mar 31, 2017 19:38
by Wuzzy
How can I use the decorations API to spawn simple decorations underground?
For example, placing mushrooms on top of stone in caves.
Or do I have to use LuaVoxelManip (or similar)?

With my experiments so far, I only managed to make mushrooms appear at Y chunk borders.

Re: Post your mapgen questions here (modding or engine)

Posted: Fri Mar 31, 2017 22:20
by FaceDeer
Wuzzy wrote:How can I use the decorations API to spawn simple decorations underground?
For example, placing mushrooms on top of stone in caves.
Or do I have to use LuaVoxelManip (or similar)?

With my experiments so far, I only managed to make mushrooms appear at Y chunk borders.
I don't know of a way to use the decorations API for this (and will be keenly interested if someone knows of a way), but in the meantime you might find this mod I've been working on recently to be of use: subterrane. If you make a mod that depends on this and then call subterrane:register_cave_decor for a range of depths, a mapgen callback will be registered that will call some methods you can specify on biomes to add decorations to the floor and ceiling of caves.

I've been making use of subterrane as the basis for my Dwarf Fortress cavern mod and I also rewrote Caverealms to be able to use it, so it seems reasonably solid.

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Apr 01, 2017 03:39
by paramat
Wuzzy wrote:With my experiments so far, I only managed to make mushrooms appear at Y chunk borders.
Yes this is all that is possible currently, because decorations can only be placed on the highest surface in a mpchunk, so only where caves intersect a mapchunk border.

I intend to add underground decorations before next release.

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Apr 02, 2017 17:58
by Mator
Just found out about Minetest today and I'm really excited because of the high world size limit. I'm a fractal enthusiast and have been interested in generating voxel representations of fractal objects for a many years now. Awhile back I made a WorldEdit script to generate fractals in Minecraft. Soon after that I made my own voxel engine in Java, and later an improved version in C++ (all with the specific purpose of generating fractals).

What I'd like to do is create new map generation presets for generating certain fractal objects, and eventually a mixed "fractal garden" preset. I'm still poking around to get a feel for how I would do this, noticed the flat map generator which looks like a good starting point.

Any recommendations for things I should look into/read going into this?

Cheers,
- Mator

EDIT: Got some help from paramat in IRC. Thanks man!