Post your mapgen questions here (modding or engine)

Post Reply
User avatar
MinisterFarrigut
Member
Posts: 75
Joined: Fri Oct 14, 2016 14:59
In-game: singleplayer
Location: The ruins of my basement

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

by MinisterFarrigut » Post

I would love an ocean mod, with fish and sea life. I need somewhere to put the boats I have built. If this can be accomplished, let me know. : )
I build buildings. I don't usually make mods...I use them.

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

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

by BrunoMine » Post

How can I calculate a mapblock coordinate from a real coordinate?

Example:

Code: Select all

pos = {x=4345, y=0, z=-22332}

mapblock_pos = ????

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

nomohakon,
For examples of singlenode mapgens see my lua mapgens https://github.com/paramat?tab=repositories
The mod with the best example of good up to date code is 'stability' https://github.com/paramat/stability

To set a particular node to be the 'single node' use a mod with this code:

Code: Select all

minetest.register_alias("mapgen_singlenode", "default:stone")
Last edited by paramat on Sun Dec 25, 2016 01:20, edited 1 time in total.

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

MinisterFarrigut,
You can alter the noise parameters to lower terrain, to make more ocean.
Last edited by paramat on Sun Dec 25, 2016 01:19, edited 1 time in total.

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

Brunomine,
For each axis and nodepos co-ord 'p':
If p >= 0:
blockpos = math.floor(p / 16)
Else:
blockpos = math.floor((p - 15) / 16)

'Block zero' is from 0 to 15.

KCoombes
Member
Posts: 427
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt
Location: SW Florida, USA

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

by KCoombes » Post

paramat, is there a way to add more mg-specific flags? without having to mess with C++ and recompiling? If not, might I suggest a 'nolava' flag? Or perhaps you could share a way of limiting the amount of lava_source that is generated?

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

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

by hajo » Post

KCoombes wrote:more mg-specific flags? I suggest a 'nolava' flag?
a way of limiting the amount of lava_source ?
Maybe lava can be 'fixed' after the mapgen has run,
eg. with a mod that looks for lava and changes it to something else
(like dirt --> dirt-with-grass), or generates a water-source nearby...

crazy_baboon
Member
Posts: 96
Joined: Sat Oct 17, 2015 10:47

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

by crazy_baboon » Post

Hi all,

I am trying to create a custom map generator. I found this http://dev.minetest.net/Mapgen.

1. Is the piece of code at the bottom Boilerplate Mapgen Code meant to be a .h file called for instance, mapgentest.h to be located in the /src directory?

2. If so what would be #includes I would have to write on the top of this mapgentest.h?

3. In which source code files would I have to write #include "mapgentest.h"

Thanks

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

Best ignore that 'Boilerplate Mapgen Code' as it's wiki documentation and very out of date.

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

> is there a way to add more mg-specific flags? without having to mess with C++ and recompiling?

Nope.

Too many lava caves? There isn't a parameter that can alter their rarity.
A way to disable lava will probably not be approved, the flags tend to be for very large and fundamental parts of mapgen.

zing269
Member
Posts: 109
Joined: Sat Apr 30, 2016 19:10

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

by zing269 » Post

KCoombes wrote:paramat, is there a way to add more mg-specific flags? without having to mess with C++ and recompiling? If not, might I suggest a 'nolava' flag? Or perhaps you could share a way of limiting the amount of lava_source that is generated?
The simplest way is to eliminate lava is to create a one line mod something like:

Code: Select all

minetest.register_alias_force("mapgen_lava_source", "default:stone")
and make it depend on default.

To reduce the amount of lava you could use hajo's suggestion to write a mod that selectively replaces some of the lava_source blocks with something else.

crazy_baboon
Member
Posts: 96
Joined: Sat Oct 17, 2015 10:47

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

by crazy_baboon » Post

sorry double post here

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

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

by TumeniNodes » Post

I am sure it has been asked before but, I'm having trouble finding any posts regarding this (sorry if I overlooked any which may exist)

My question is simple (the answer, maybe not so simple :P )

For my subgame, I want to reduce biomes down to just one. Just the average, grassy land with dirt and grass, stone, sandy beaches, trees (but only aspen, apple_tree, and pine which I know how to take care of but jungletrees are really invasive to the terrain when stripped out)... etc..
How the heck do I do that? :D

I stripped out all but one biome with mapgen but, wound up with vast areas of Unknown Nodelands (which might be a cool map some day :P,... and cool looking but, also strange areas where jungletrees should be.
I had also resorted (lastly) to simply changing all top and filler nodes with either grass, dirt, etc... in all the other biomes.

I guess if the least I can strip down to is 2 biomes, I'd prefer to have the majority (as I described above) and maybe a small area of just sand... (like a mini sand pit?)

Anyway, I await the answer, and thank you in advance
A Wonderful World

User avatar
duane
Member
Posts: 1715
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

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

by duane » Post

TumeniNodes wrote: For my subgame, I want to reduce biomes down to just one. Just the average, grassy land with dirt and grass, stone, sandy beaches, trees (but only aspen, apple_tree, and pine which I know how to take care of but jungletrees are really invasive to the terrain when stripped out)... etc..
How the heck do I do that? :D
It sounds like you want this, more or less:

Code: Select all

-- Copy the good biomes.
local rereg = {}
for i, rbi in pairs(minetest.registered_biomes) do
    -- Keep only two biomes.
    if rbi.name == 'deciduous_forest' then
        rereg[#rereg+1] = table.copy(rbi)
        -- Change the altitude so it won't suck up the coastline.
        rereg[#rereg].y_min = 4
    end
    if rbi.name == 'sandstone_grassland_ocean' then
        rereg[#rereg+1] = table.copy(rbi)
    end
end

minetest.clear_registered_biomes()

-- Reregister the good biomes.
for _, bi in pairs(rereg) do
    minetest.register_biome(bi)
end

-- Copy good decorations.
rereg = {}
for _, dec in pairs(minetest.registered_decorations) do
    local keep = false
    for _, bi in pairs(dec.biomes) do
        if bi == 'deciduous_forest' or bi == 'sandstone_grassland_ocean' then
            keep = true
        end
    end
    if keep then
        rereg[#rereg+1] = dec
    end
end

minetest.clear_registered_decorations()

-- Reregister decorations.
for _, dec in pairs(rereg) do
    minetest.register_decoration(dec)
end
rereg = nil
You still need two biomes to get sandy beaches, and you have to remember to kill any decorations that don't belong, otherwise they pop up everywhere.
Believe in people and you don't need to believe anything else.

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

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

by TumeniNodes » Post

duane wrote:
TumeniNodes wrote: For my subgame, I want to reduce biomes down to just one. Just the average, grassy land with dirt and grass, stone, sandy beaches, trees (but only aspen, apple_tree, and pine which I know how to take care of but jungletrees are really invasive to the terrain when stripped out)... etc..
How the heck do I do that? :D
It sounds like you want this, more or less:

Code: Select all

-- Copy the good biomes.
local rereg = {}
for i, rbi in pairs(minetest.registered_biomes) do
    -- Keep only two biomes.
    if rbi.name == 'deciduous_forest' then
        rereg[#rereg+1] = table.copy(rbi)
        -- Change the altitude so it won't suck up the coastline.
        rereg[#rereg].y_min = 4
    end
    if rbi.name == 'sandstone_grassland_ocean' then
        rereg[#rereg+1] = table.copy(rbi)
    end
end

minetest.clear_registered_biomes()

-- Reregister the good biomes.
for _, bi in pairs(rereg) do
    minetest.register_biome(bi)
end

-- Copy good decorations.
rereg = {}
for _, dec in pairs(minetest.registered_decorations) do
    local keep = false
    for _, bi in pairs(dec.biomes) do
        if bi == 'deciduous_forest' or bi == 'sandstone_grassland_ocean' then
            keep = true
        end
    end
    if keep then
        rereg[#rereg+1] = dec
    end
end

minetest.clear_registered_decorations()

-- Reregister decorations.
for _, dec in pairs(rereg) do
    minetest.register_decoration(dec)
end
rereg = nil
You still need two biomes to get sandy beaches, and you have to remember to kill any decorations that don't belong, otherwise they pop up everywhere.
Thank you duane, I'll give this a try.... ummmm, where do I stick it? :P

Is this a minetest.conf thing? or a mapgen.lua thing?
I already have everything else stripped down and set up, ready to go...

I was hoping to be able to strip out all the code in mapgen, for all the biomes I don't want. Is that what this does? Do I just delete all the biomes and stick this code in there instead?

Sorry for adding another question

For a little more info, I have removed all the desert, snow, cold, jungle, and sahara related nodes and decos (aside from the trees I'll deal with the acacia and jungletrees later
A Wonderful World

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

Just write a mod (depending on default) that has
minetest.clear_registered_biomes()
at the start, then copy-paste from default/mapgen.lua the biome registrations you want.
Example mod that does something similar https://github.com/paramat/newbiomes/bl ... r/init.lua
If you have only one biome (plus one beach biome plus one ocean biome, all vertically stacked) then make sure all have heat / humidity point = 50 (middle value).

Just realised you are making a subgame, in which case just edit mapgen.lua and remove the unwanted biomes, then edit the heat / humidity point values so that they are nicely spaced out on the voronoi diagram (see diagram viewtopic.php?f=18&t=15939).

> I stripped out all but one biome with mapgen but, wound up with vast areas of Unknown Nodelands

Did you start a new world before trying this?

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

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

by TumeniNodes » Post

paramat wrote:Just write a mod (depending on default) that has
minetest.clear_registered_biomes()
at the start, then copy-paste from default/mapgen.lua the biome registrations you want.
Example mod that does something similar https://github.com/paramat/newbiomes/bl ... r/init.lua
If you have only one biome (plus one beach biome plus one ocean biome, all vertically stacked) then make sure all have heat / humidity point = 50 (middle value).

Just realised you are making a subgame, in which case just edit mapgen.lua and remove the unwanted biomes, then edit the heat / humidity point values so that they are nicely spaced out on the voronoi diagram (see diagram viewtopic.php?f=18&t=15939).
Alrighty... I'll give that a whirl then.Thank you...


> I stripped out all but one biome with mapgen but, wound up with vast areas of Unknown Nodelands
paramat wrote:Did you start a new world before trying this?
Of course I did... psshh <It's a lie..., no he didn't.
A Wonderful World

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

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

by TumeniNodes » Post

Thank you duane for the code, I know where it would have gone now ; )

And thank you paramat... worked like a charm....
But HOLY CUCKIES!!!! which lines in the trees codings in mapgen will thin out the trees a bit? (a lot actually)

hehe... I believe reducing the number of biomes cause my map to have literally every single node covered with refugee trees :P
A Wonderful World

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

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

by TumeniNodes » Post

Ok, so I want to greatly thin out the trees in mapgen.. but seems what I have done so far has zero impact?
Obviously, I am not changing the correct areas.

Normally when I have no idea what I'm doing, I just start making randome changes (one at a time) to see if something changes, and in what ways so...
And yes, each time I make changes, I wipe meta.txt, map.sqlite, forceload, and env_meta.txt and then restart the world
Guidance would be greatly appreciated : ) thank you

this is what I have done so far and, again, as I said No doff in density of the trees at all. I figured Id start by changing probabilities and persists first to see if there were any changes and..., none

Code: Select all

	-- Apple tree and log

	minetest.register_decoration({
		deco_type = "schematic",
		place_on = {"default:dirt_with_grass"},
		sidelen = 16,
		noise_params = {
			offset = 0.036,
			scale = 0.022,
			spread = {x = 250, y = 250, z = 250},
			seed = 2,
			octaves = 3,
			persist = 0.22
		},
		biomes = {"coniferous_forest"},
		y_min = 1,
		y_max = 31000,
		schematic = minetest.get_modpath("default").."/schematics/apple_tree.mts",
		flags = "place_center_x, place_center_z",
	})

	minetest.register_decoration({
		deco_type = "schematic",
		place_on = {"default:dirt_with_grass"},
		sidelen = 16,
		noise_params = {
			offset = 0.0018,
			scale = 0.0011,
			spread = {x = 250, y = 250, z = 250},
			seed = 2,
			octaves = 3,
			persist = 0.22
		},
		biomes = {"coniferous_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:apple_tree", param2 = 12, prob = 50},
				{name = "default:apple_tree", param2 = 12},
				{name = "default:apple_tree", param2 = 12, prob = 60},
				{name = "air", prob = 0},
				{name = "flowers:mushroom_brown", prob = 63},
				{name = "air", prob = 0},
			},
		},
		flags = "place_center_x",
		rotation = "random",
	})

	-- Taiga and temperate coniferous forest pine tree and log

	minetest.register_decoration({
		deco_type = "schematic",
		place_on = {"default:dirt_with_grass"},
		sidelen = 16,
		noise_params = {
			offset = 0.036,
			scale = 0.022,
			spread = {x = 250, y = 250, z = 250},
			seed = 2,
			octaves = 3,
			persist = 0.22
		},
		biomes = {"coniferous_forest"},
		y_min = 2,
		y_max = 31000,
		schematic = minetest.get_modpath("default").."/schematics/pine_tree.mts",
		flags = "place_center_x, place_center_z",
	})

	minetest.register_decoration({
		deco_type = "schematic",
		place_on = {"default:dirt_with_grass"},
		sidelen = 80,
		noise_params = {
			offset = 0.0018,
			scale = 0.0011,
			spread = {x = 250, y = 250, z = 250},
			seed = 2,
			octaves = 3,
			persist = 0.22
		},
		biomes = {"coniferous_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:pine_tree", param2 = 12, prob = 40},
				{name = "default:pine_tree", param2 = 12},
				{name = "default:pine_tree", param2 = 12, prob = 50},
				{name = "air", prob = 0},
				{name = "flowers:mushroom_red", prob = 63},
				{name = "air", prob = 0},
			},
		},
		flags = "place_center_x",
		rotation = "random",
	})

	-- Aspen tree and log

	minetest.register_decoration({
		deco_type = "schematic",
		place_on = {"default:dirt_with_grass"},
		sidelen = 16,
		noise_params = {
			offset = 0.0,
			scale = -0.015,
			spread = {x = 250, y = 250, z = 250},
			seed = 2,
			octaves = 3,
			persist = 0.22
		},
		biomes = {"coniferous_forest"},
		y_min = 1,
		y_max = 31000,
		schematic = minetest.get_modpath("default").."/schematics/aspen_tree.mts",
		flags = "place_center_x, place_center_z",
	})

	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.22
		},
		biomes = {"coniferous_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 = 35},
				{name = "flowers:mushroom_red", prob = 63},
				{name = "flowers:mushroom_brown", prob = 63},
				{name = "air", prob = 0},
			},
		},
		flags = "place_center_x",
		rotation = "random",
	})
I have kept only the coniferous forest and set these three types into it... and well, I was not expecting this many guests :P
Image
My goal is to have tree clusters but in small, open forests areas (much like Europe was when they used up all their wood, building ships etc..) So yep, thinly spread tree production is desired here
Attachments
treefugees.png
treefugees.png (498.77 KiB) Viewed 700 times
A Wonderful World

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

I guess if a biome is not found a decoration will then be placed in all biomes, so also delete any unwanted decorations.

Don't touch 'persist'. You want to adjust 'offset' and 'scale'.
'offset' is the average density, 'scale' is the density variation either side of 'offset'.
So for patches set 'offset' to 0.0, this way exactly half the surface area is covered by that decoration.
Since you have 3 tree types in one biome you need to reduce 'scale' to reduce density.
'spread' is the rough spacing of the patches, in nodes, so you may want to reduce that.

Then, for logs to have the same distribution as the corresponding tree, make sure the noise params for the log matches the tree, except, simply halve 'offset' and 'scale'.

Note that all tree types have the same 'seed' so their distributions will be similar as in your screenshot, differing seeds will create differing distributions.

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

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

by TumeniNodes » Post

paramat wrote:I guess if a biome is not found a decoration will then be placed in all biomes, so also delete any unwanted decorations.

Don't touch 'persist'. You want to adjust 'offset' and 'scale'.
'offset' is the average density, 'scale' is the density variation either side of 'offset'.
So for patches set 'offset' to 0.0, this way exactly half the surface area is covered by that decoration.
Since you have 3 tree types in one biome you need to reduce 'scale' to reduce density.
'spread' is the rough spacing of the patches, in nodes, so you may want to reduce that.

Then, for logs to have the same distribution as the corresponding tree, make sure the noise params for the log matches the tree, except, simply halve 'offset' and 'scale'.

Note that all tree types have the same 'seed' so their distributions will be similar as in your screenshot, differing seeds will create differing distributions.
Awesome and detailed info again paramat... thank you very much!

I better go take care of all this then... the trees are getting anxious n roudy...
and you're right about persist... a few of them slapped me and seemed extremely nervous and upset when I touched their persists.... now I know why.

edit> I think what I'm gonna do (if you're o.k. with it, don't see why you wouldn't be)... is to add a "mapgen_info.txt" doc in my subgame to show info given here in this thread to me, and how it was used to make various changes to create whatever landscape comes of all this...
It should be useful to others who might want to try poking and pushing buttons..
A Wonderful World

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

That's fine by me, quote anything you want.

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

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

by TumeniNodes » Post

paramat wrote:That's fine by me, quote anything you want.
Thank you
A Wonderful World

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

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

by Sergey » Post

What mapgen is more realistic? I tried all of them. One makes flat desert with no trees nearby (boring), another -- rocks floating in the sky (wtf?), third -- puts me in the middle of the jungle that are near snowy hills(!), and so on.

What makes more realistic landcape? For example, quite big islands in the sea (with mountails, hills, fields, maybe enclosed lakes, full of plants and trees). And mainland (continent) with rich flora not so far away that has rivers floods into that sea. Tropic, Pacific, ...

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

> One makes flat desert with no trees nearby (boring)

You have to travel to see the other biomes.

> third -- puts me in the middle of the jungle that are near snowy hills(!)

We try to separate hot and cold biomes, but due to the nature of noise sometimes hot and cold biomes can be fairly close, if we made the heat/humidity variations larger scale then some biomes would be too big, it's a difficult balance.

> What makes more realistic landcape? For example, quite big islands in the sea (with mountails, hills, fields, maybe enclosed lakes, full of plants and trees). And mainland (continent) with rich flora not so far away that has rivers floods into that sea. Tropic, Pacific, ...

Heh we don't have anyhting like that, some of what you describe is difficult to do. But i am working on something that is more realistic, larger scale.

Mgvalleys is probably the most realistic so far (scroll down the mapgen list to see it).

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 6 guests