I don't understand how to use mapgen.

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

I don't understand how to use mapgen.

by Chinchow » Sat Sep 07, 2013 00:09

I have read the modding API for mapgen and I don't get it.
I have tried looking at mods that add biomes(snow biome).
I just have not been able to understand it.
If anyone could explain mapgen to me I would appreciate it, if not it's alright.
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

by Chinchow » Sat Sep 07, 2013 13:43

The only thing I figured out how to spawn was ores(not that hard) but I can't figure out how to spawn plants or make a biomes like Splizard did.
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

by Chinchow » Sat Sep 07, 2013 23:37

Yes I looked at it but it just isn't as easy to understand as the normal item registration code.
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 

leetelate
Member
 
Posts: 205
Joined: Thu Aug 29, 2013 18:07

by leetelate » Sun Sep 22, 2013 02:02

LULZ! so you make a folder called ouch in the mods folder, create an empty file called depends.txt with the one word 'default' in it (no quotes - needed so it can find the defaults table to get the cobble id), then create an empty file called init.lua, insert the code, create a new world USING THE SINGLENODE IN THE MAPGEN DROPDOWN, enable the new ouch mod then hit play - you are now inside a solid world of cobblestone! - even if you had a pickaxe (or changed the cobble to default:sand), you can never dig your way out because the mapgen you just created creates a new area ahead of your digging!!!

priceless!!! and a great tutorial on the basic mapgen mod!!!

THANK YOU!!!

+1^5362437436 to hybrid dog!!!
Last edited by leetelate on Sun Sep 22, 2013 02:49, edited 1 time in total.
MT IS MC'S SMARTER BROTHER
minetest 0.4.8 compiled from latest git on linux mint 15 with qjoypad and wired 360 controller
freeminer, pilztest, buildcraft and next are the idea factories
my minetest page is http://1337318.zymichost.com if zymic isn't down - meh, it is free...
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

by paramat » Sun Sep 22, 2013 02:49

There's a more interesting mapgen example here (requires 0.4.7dev/0.4.8 Minetest) https://forum.minetest.net/viewtopic.php?id=6396
Now just experiment with the code inside the triple xyz loop, use maths and perlin noise to add different nodes.
Last edited by paramat on Sun Sep 22, 2013 02:50, edited 1 time in total.
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 

leetelate
Member
 
Posts: 205
Joined: Thu Aug 29, 2013 18:07

by leetelate » Sun Sep 22, 2013 03:49

thanks!!!

like:
if y > 0 then --above ground
data[area:index(x, y, z)] = c_air
else -- doing the ground
--handle -x and -z be snow, etc - depth will be unlimited
if x<0 and z<0 and y<0 then
data[area:index(x, y, z)] = c_stone
end
if x>=0 and z<0 and y<0 then
data[area:index(x, y, z)] = c_sand
end
if x<0 and z>=0 and y<0 then
data[area:index(x, y, z)] = c_water
end
if x>=0 and z>=0 and y<0 then
data[area:index(x, y, z)] = c_dirt
end
end --if the air

one area is like 80*80*80 nodes - whew! no wonder they write it in c!

be nice if there were a way in lua to fill arrays, oh wait there is pipes! - http://lua-users.org/wiki/FiltersAndPipesReloaded

function my_filter( pInput, pOutput )
while ... do
...
... = pInput()
...
pOutput( ... )
...
end

so a pipe we make to take our perlin nose, transform it with the content as it goes into the pipe - and to get it out we unpack() it

like in the villages mapgen https://forum.minetest.net/viewtopic.php?id=7263 - very complicated for me

ok, I get it, now on to my mapgen from a picture (picture with height info, like in 3d printing) - you have been wonderful and thank you!

"when, from defaults we fill with the id's of the textures for" <-- why I don't write explanations
Last edited by leetelate on Sun Sep 22, 2013 04:57, edited 1 time in total.
MT IS MC'S SMARTER BROTHER
minetest 0.4.8 compiled from latest git on linux mint 15 with qjoypad and wired 360 controller
freeminer, pilztest, buildcraft and next are the idea factories
my minetest page is http://1337318.zymichost.com if zymic isn't down - meh, it is free...
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

by paramat » Sun Sep 22, 2013 07:17

leetelate wrote: if y > 0 then --above ground
data[area:index(x, y, z)] = c_air
else -- doing the ground
--handle -x and -z be snow, etc - depth will be unlimited
if x<0 and z<0 and y<0 then
data[area:index(x, y, z)] = c_stone
end
if x>=0 and z<0 and y<0 then
data[area:index(x, y, z)] = c_sand
end
if x<0 and z>=0 and y<0 then
data[area:index(x, y, z)] = c_water
end
if x>=0 and z>=0 and y<0 then
data[area:index(x, y, z)] = c_dirt
end
end --if the air

Yes but use if-then-elseif-then-else-end statements wherever possible to avoid unnecessary processing.
Last edited by paramat on Sun Sep 22, 2013 07:19, edited 1 time in total.
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

by paramat » Sun Sep 22, 2013 07:58

Forum member hmmmm is the Minetest mapgen dev, his example there is simple '3D noise mixed with a gradient type', explained simply on this page by celeron55, it describes a previous Minetest mapgen V5 http://c55.me/random/2011-07/noisestuff/
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
if nvals[ni] - (y - 25) / 55 > 0.5 then

nvals[ni] is the 3D noise.
- (y - 25) / 55 is the gradient, this term has value zero at y = 25, goes negative above and positive below.
0.5 is the density threshold for a solid node.
nvals[ni] - (y - 25) / 55 can be thought of as density.
So the line above means 'if density is above the chosen threshold then make node solid' with whatever material.
Last edited by paramat on Sun Sep 22, 2013 08:11, edited 1 time in total.
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

by paramat » Sun Sep 22, 2013 10:50

if noise - gradient > threshold then make node solid.
If there was only noise, the world would be an asteroid field of floating blobs. If there was only gradient, there would be a flatland world.

Some calculations only need to be done once per column, usually choosing the biome, so it's better to order the triple loop XZ Y, working through each column in a chunk, and for each column working either upwards or downwards depending on the advantages. So biome choosing code goes after 'for z = ... do' and before 'for y = ... do'.
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 


Return to WIP Mods

Who is online

Users browsing this forum: Majestic-12 [Bot] and 9 guests

cron