Compare commits

...

5 Commits

Author SHA1 Message Date
Sokomine 8df6a47610 added lake_chance parameter for reducing amount of lakes 2019-08-04 17:18:27 +02:00
Sokomine 11bff36c3b corrected volume; lakes can have min depth, surface area and volume 2019-08-04 17:11:48 +02:00
Sokomine d4e1be43f2 made clay a config variable 2019-08-03 22:43:23 +02:00
Sokomine 9b299cd947 extended depends.txt 2019-08-03 22:43:01 +02:00
Sokomine 0496300bf5 remove snowblocks on trees as well 2019-08-03 22:23:02 +02:00
2 changed files with 61 additions and 14 deletions

View File

@ -1 +1,4 @@
default
moreblocks?
aotearoa?
trees?

View File

@ -1,6 +1,23 @@
lakes = {}
lakes.ground_material = "default:clay";
lakes.fill_lake_with = "default:river_water_source";
-- do not generate lakes...
-- ...less than this deep
lakes.min_depth = 1
-- ...with less square meters surface than this value
lakes.min_surface_area = 9
-- ...with a volume less than this value
lakes.min_volume = 18
-- probability of a possible lake actually beeing generated in percent
-- (depends on mapgen how many chances there are)
-- if set to 100: generate as many lakes as possible
-- if set to 0: generate no lakes
lakes.lake_chance = 100
-- plant these plants around lakes
lakes.plants_around_lakes = {
"default:grass_5", "default:grass_5", "default:grass_5",
@ -26,7 +43,6 @@ lakes.around_lake_decorations = {
}
local fill_lake_with = "default:river_water_source";
-- helper function for mark_min_max_height_in_mapchunk(..)
-- math_extrema: math.min for maxheight; math.max for minheight
@ -214,13 +230,13 @@ local identify_individual_holes_or_hills = function( minp, maxp, ax, az, i, chun
minp = {x=ax, z=az, y=math.min(h_max, h_real)},
maxp = {x=ax, z=az, y=math.max(h_max, h_real)},
size = 1,
volume = ay,
volume = h_real,
};
else
-- the surface area is one larger now
hole_data[ id ].size = hole_data[ id ].size + 1;
-- the volume has also grown
hole_data[ id ].volume = hole_data[ id ].volume + ay;
hole_data[ id ].volume = hole_data[ id ].volume + h_real;
if( ax < hole_data[ id ].minp.x ) then
hole_data[ id ].minp.x = ax;
end
@ -229,8 +245,7 @@ local identify_individual_holes_or_hills = function( minp, maxp, ax, az, i, chun
hole_data[ id ].maxp.x = math.max( ax, hole_data[ id ].maxp.x );
hole_data[ id ].minp.z = math.min( az, hole_data[ id ].minp.z );
hole_data[ id ].maxp.z = math.max( az, hole_data[ id ].maxp.z );
hole_data[ id ].minp.y = math.min( ay, hole_data[ id ].minp.y );
hole_data[ id ].maxp.y = math.max( ay, hole_data[ id ].maxp.y );
hole_data[ id ].minp.y = math.min( h_real, hole_data[ id ].minp.y );
end
end
return hole_counter;
@ -261,7 +276,6 @@ local merge_if_same_hole_or_hill = function(hole_data, merge_into)
merged[v].minp.z = math.min( merged[v].minp.z, hole_data[k].minp.z );
merged[v].maxp.z = math.max( merged[v].maxp.z, hole_data[k].maxp.z );
merged[v].minp.y = math.min( merged[v].minp.y, hole_data[k].minp.y );
merged[v].maxp.y = math.max( merged[v].maxp.y, hole_data[k].maxp.y );
end
id2merged[ k ] = id2merged[ v ];
end
@ -485,11 +499,30 @@ minetest.register_on_generated(function(minp, maxp, seed)
-- flatten hills, fill holes (just virutal in adjusted_heightmap)
local adjusted_heightmap = heightmap_with_hills_lowered_and_holes_filled( minp, maxp, heightmap, extrema, detected);
-- calculate the actual volume now
for k,v in pairs(detected.holes.merged) do
-- we did sum up the height at ground level at each point;
-- the lake will be between target_height and that ground level
v.volume = (v.size * v.target_height) - v.volume;
-- what's the maximum depth of this lake?
v.depth = v.target_height - v.minp.y;
end
-- for now: fill each hole (no matter how big or tiny) with river water
for id, data in pairs( detected.holes.merged ) do
detected.holes.merged[id].material = fill_lake_with;
local hole = detected.holes.merged[id];
detected.holes.merged[id].material = lakes.fill_lake_with;
-- skip lakes that do not fit the minimal requirements
if( hole.depth < lakes.min_depth
or hole.size < lakes.min_surface_area
or hole.volume < lakes.min_volume ) then
detected.holes.merged[id].material = nil;
end
-- skip lakes because less lakes are wanted
if( lakes.lake_chance < 100 and lakes.lake_chance < math.random(0, 100)) then
detected.holes.merged[id].material = nil;
end
end
-- show something to the user; change the landscape
@ -500,22 +533,23 @@ minetest.register_on_generated(function(minp, maxp, seed)
i = i+1;
-- is there a hole?
if( detected.holes_markmap[i] and detected.holes_markmap[i]>0) then
if( detected.holes_markmap[i]
and detected.holes_markmap[i]>0
and detected.holes.merged[detected.holes_merge_into[ detected.holes_markmap[i] ]].material) then
local id = detected.holes_merge_into[ detected.holes_markmap[i] ];
local hole = detected.holes.merged[id];
-- is there a node *above* the future surface of the lake?
-- this might be a tree with leaves, fruits and/or snow on it
local n = minetest.get_node({x=ax, z=az, y=hole.target_height+1});
if( n and n.name and n.name ~= "ignore" and n.name ~= "air") then
local remove = minetest.find_nodes_in_area(
{x=ax-3, y=heightmap[i], z=az-3},
{x=ax+3, y=heightmap[i]+16, z=az+3},
{x=ax+3, y=heightmap[i]+18, z=az+3},
-- tree trunks. leaves and tree fruits
{"group:tree", "group:leaves", "default:apple",
-- snow on pines has to go as well
"default:snow"});
"default:snow", "default:snowblock"});
for nr, pos in ipairs(remove) do
minetest.set_node( pos, {name = "air"}); --"default:obsidian_glass"});
end
@ -523,9 +557,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
-- clay is a nice building material; we need more of it!
-- thus: turn the ground of the lake into clay
minetest.set_node( {x=ax, z=az, y=heightmap[i]}, {name="default:clay"});
-- is there a node above the *ground*? (most likely a plant)
minetest.set_node( {x=ax, z=az, y=heightmap[i]}, {name=lakes.ground_material});
-- this is only of intrest if the node will not be replaced anyway (that is,
-- the node is not at the lakes surface)
if(heightmap[i] < hole.target_height-1) then
@ -537,6 +569,18 @@ minetest.register_on_generated(function(minp, maxp, seed)
-- place the fill material at the new surface height of the lake
minetest.set_node( {x=ax, z=az, y=hole.target_height}, {name=hole.material});
--[[
-- if a pointable node - i.e. default:glass - is used as
-- lakes.fill_lake_with, then this here can be uncommented to
-- get debug information about the lake
local meta = minetest.get_meta( {x=ax, z=az, y=hole.target_height});
meta:set_string("infotext","Lake ID: "..tostring(id).." "..tostring(hole.size)..
" m^2; Volume: "..tostring(hole.volume)..
" m^3; Max. Depth: "..tostring(hole.depth));
--]]
-- is there a node above the *ground*? (most likely a plant)
-- waterlilys are decorative
if(minetest.registered_nodes["flowers:waterlily"] and math.random(1,20)==1) then
minetest.set_node( {x=ax, z=az, y=hole.target_height+1}, {name="flowers:waterlily"});