implemented biome dependent tree generation

This commit is contained in:
Kurtzmusch 2020-04-29 14:39:20 -03:00
parent bcfb7dcf94
commit 13b3a08ec8
3 changed files with 39 additions and 38 deletions

View File

@ -63,7 +63,7 @@ local REALM_FINISH = REALM_START+HEIGHT_VARIANCE
-- debug stuff
local DEBUG_FLAGS = { debug_blocks=false, overwrite_seed = true, cherrypicked_spawn = false, cherrypick_biome=true, give_privs=true }
local DEBUG_FREQUENCY = 5
local DESIRED_BIOME = "bluelands"
local DESIRED_BIOME = "cyanlands"
local debug_data = {
mapblock_count = 0,
timeAccumulator_total = 0,
@ -78,24 +78,19 @@ local schematics_path = minetest.get_modpath("ether_lands").."/schematics/"
ether_lands.schematics = {
path = minetest.get_modpath("ether_lands").."/schematics/",
cyanlands_tree1 = schematics_path.."cyanlands_tree1.mts",
cyanlands_tree2 = schematics_path.."cyanlands_tree2.mts",
cyanlands_tree3 = schematics_path.."cyanlands_tree3.mts",
cyanlands = {
tree1 = schematics_path.."cyanlands_tree1.mts",
tree2 = schematics_path.."cyanlands_tree2.mts",
tree3 = schematics_path.."cyanlands_tree3.mts",
},
orangelands = {
tree1 = schematics_path.."orangelands_tree1.mts",
},
bluelands = {
tree1 = schematics_path.."bluelands_tree1.mts",
},
}
minetest.register_chatcommand("testschem", {
func = function( name, param )
minetest.place_schematic(
minetest.string_to_pos(param),
ether_lands.schematics.cyanlands_tree1,
"random",
nil,
true,
"place_center_x,place_center_z"
)
end
})
-- noise parameters -----------------------------------------------------------
ether_lands.heightmap_parameters = {
@ -162,7 +157,7 @@ local mapchunk_length -- assumes mapchunks and emerged vmanips are always cubes
local emerged_length
minetest.register_on_mapgen_init( function(mapgen_params)
if( DEBUG_FLAGS.overwrite_seed ) then minetest.set_mapgen_setting("seed", 10200000, true) end
if( DEBUG_FLAGS.overwrite_seed ) then minetest.set_mapgen_setting("seed", 10300000, true) end
mapchunk_length = minetest.get_mapgen_setting("chunksize")*16 --TODO 16 should not be hard coded
emerged_length = mapchunk_length+(16*2) --TODO figure out if emerged areas is always 1 mapblock bigger in all directions
@ -195,32 +190,38 @@ function( cid_data, generate_VoxelArea, buffer_VoxelArea )
local node_index_in_mapchunk
local node_2d_index = 1
local grass_id = cid_grass_cyan
for z = zmin, zmax do
for y = ymin, ymax do
for x = xmin, xmax do
local base_height = heightmap_values[node_2d_index] --TODO cache this for every x,z only
base_height = (base_height+1)/2
base_height = base_height * HEIGHT_VARIANCE
local grass_id
local trees_schematics
if ( base_height > ORANGELANDS_BIOME_HEIGHT ) then
grass_id = cid_grass_cyan
trees_schematics = ether_lands.schematics.cyanlands
end
if( base_height > BLUELANDS_BIOME_HEIGHT ) then
grass_id = cid_grass_blue
trees_schematics = ether_lands.schematics.bluelands
end
if( base_height < ORANGELANDS_BIOME_HEIGHT ) then
grass_id = cid_grass_orange
trees_schematics = ether_lands.schematics.orangelands
end
local node_index_in_emerged = buffer_VoxelArea:index(x,y,z)
if( cid_data[node_index_in_emerged] == grass_id ) then
if( math.random() < TREE_FREQUENCY ) then
if( math.random() < TREE3_FREQUENCY ) then
minetest.place_schematic(
{x=x, y=y, z=z},
ether_lands.schematics.cyanlands_tree3,
"random",
nil,
true,
"place_center_x,place_center_z"
)
else
minetest.place_schematic(
{x=x, y=y, z=z},
ether_lands.schematics.cyanlands_tree2,
"random",
nil,
true,
"place_center_x,place_center_z"
)
end
minetest.place_schematic(
{x=x, y=y, z=z},
trees_schematics.tree1,
"random",
nil,
true,
"place_center_x,place_center_z"
)
end
end
end

Binary file not shown.

Binary file not shown.