mirror of
https://github.com/mt-mods/plantlife_modpack.git
synced 2025-07-13 13:30:19 +02:00
Compare commits
3 Commits
replace_bi
...
molehills_
Author | SHA1 | Date | |
---|---|---|---|
62b6245bd1 | |||
c6fd4a12b8 | |||
23d04af7d6 |
@ -12,9 +12,11 @@ abstract_bushes = {}
|
||||
|
||||
local bushes_bush_rarity = tonumber(minetest.settings:get("bushes_bush_rarity")) or 99.9
|
||||
local bushes_bush_rarity_fertility = tonumber(minetest.settings:get("bushes_bush_rarity_fertility")) or 1.5
|
||||
local bushes_bush_fertility = tonumber(minetest.settings:get("bushes_bush_fertility")) or -1
|
||||
|
||||
local bushes_youngtrees_rarity = tonumber(minetest.settings:get("bushes_youngtrees_rarity")) or 100
|
||||
local bushes_youngtrees_rarity_fertility = tonumber(minetest.settings:get("bushes_youngtrees_rarity_fertility")) or 0.6
|
||||
local bushes_youngtrees_fertility = tonumber(minetest.settings:get("bushes_youngtrees_fertility")) or -0.5
|
||||
|
||||
|
||||
minetest.register_node("bushes:youngtree2_bottom", {
|
||||
@ -209,17 +211,18 @@ abstract_bushes.grow_bush_node = function(pos,dir, leaf_type)
|
||||
end
|
||||
|
||||
|
||||
pl.register_on_generate({
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
"default:dirt_with_grass",
|
||||
"stoneage:grass_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
noise_params = pl.generate_noise_params({rarity = bushes_bush_rarity, rarity_fertility = bushes_bush_rarity_fertility}),
|
||||
rarity = bushes_bush_rarity,
|
||||
rarity_fertility = bushes_bush_rarity_fertility,
|
||||
plantlife_limit = bushes_bush_fertility,
|
||||
min_elevation = 1, -- above sea level
|
||||
},
|
||||
"bushes:bushes",
|
||||
abstract_bushes.grow_bush
|
||||
)
|
||||
|
||||
@ -251,16 +254,17 @@ abstract_bushes.grow_youngtree_node2 = function(pos, height)
|
||||
end
|
||||
|
||||
|
||||
pl.register_on_generate({
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
"default:dirt_with_grass",
|
||||
"stoneage:grass_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
noise_params = pl.generate_noise_params({rarity = bushes_youngtrees_rarity, rarity_fertility = bushes_youngtrees_rarity_fertility}),
|
||||
rarity = bushes_youngtrees_rarity,
|
||||
rarity_fertility = bushes_youngtrees_rarity_fertility,
|
||||
plantlife_limit = bushes_youngtrees_fertility,
|
||||
min_elevation = 1, -- above sea level
|
||||
},
|
||||
"bushes:youngtrees",
|
||||
abstract_bushes.grow_youngtree2
|
||||
)
|
||||
|
@ -62,4 +62,4 @@ minetest.register_decoration({
|
||||
param2_max = 3,
|
||||
y_min = -16,
|
||||
y_max = 48
|
||||
})
|
||||
})
|
@ -1,2 +1,2 @@
|
||||
name = cavestuff
|
||||
depends = default,biome_lib
|
||||
depends = default
|
||||
|
@ -92,42 +92,44 @@ minetest.register_node("dryplants:juncus_02", {
|
||||
-- GENERATE SMALL JUNCUS
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- near water or swamp
|
||||
pl.register_on_generate({
|
||||
surface = {
|
||||
"default:dirt_with_grass",
|
||||
--"default:desert_sand",
|
||||
--"default:sand",
|
||||
"stoneage:grass_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
noise_params = pl.generate_noise_params({max_count = JUNCUS_NEAR_WATER_PER_MAPBLOCK, rarity = 101 - JUNCUS_NEAR_WATER_RARITY}),
|
||||
min_elevation = 1, -- above sea level
|
||||
near_nodes = {"default:water_source","sumpf:dirtywater_source","sumpf:sumpf"},
|
||||
near_nodes_size = 2,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
"default:dirt_with_grass",
|
||||
--"default:desert_sand",
|
||||
--"default:sand",
|
||||
"stoneage:grass_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
"dryplants:juncus_near_water",
|
||||
abstract_dryplants.grow_juncus
|
||||
max_count = JUNCUS_NEAR_WATER_PER_MAPBLOCK,
|
||||
rarity = 101 - JUNCUS_NEAR_WATER_RARITY,
|
||||
min_elevation = 1, -- above sea level
|
||||
near_nodes = {"default:water_source","sumpf:dirtywater_source","sumpf:sumpf"},
|
||||
near_nodes_size = 2,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
abstract_dryplants.grow_juncus
|
||||
)
|
||||
-- at dunes/beach
|
||||
pl.register_on_generate({
|
||||
surface = {
|
||||
--"default:dirt_with_grass",
|
||||
--"default:desert_sand",
|
||||
"default:sand",
|
||||
--"stoneage:grass_with_silex",
|
||||
--"sumpf:peat",
|
||||
--"sumpf:sumpf"
|
||||
},
|
||||
noise_params = pl.generate_noise_params({max_count = JUNCUS_AT_BEACH_PER_MAPBLOCK, rarity = 101 - JUNCUS_AT_BEACH_RARITY}),
|
||||
min_elevation = 1, -- above sea level
|
||||
near_nodes = {"default:dirt_with_grass"},
|
||||
near_nodes_size = 2,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
--"default:dirt_with_grass",
|
||||
--"default:desert_sand",
|
||||
"default:sand",
|
||||
--"stoneage:grass_with_silex",
|
||||
--"sumpf:peat",
|
||||
--"sumpf:sumpf"
|
||||
},
|
||||
"dryplants:junces_at_beach",
|
||||
abstract_dryplants.grow_juncus
|
||||
max_count = JUNCUS_AT_BEACH_PER_MAPBLOCK,
|
||||
rarity = 101 - JUNCUS_AT_BEACH_RARITY,
|
||||
min_elevation = 1, -- above sea level
|
||||
near_nodes = {"default:dirt_with_grass"},
|
||||
near_nodes_size = 2,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
abstract_dryplants.grow_juncus
|
||||
)
|
||||
|
@ -12,13 +12,14 @@ abstract_dryplants.grow_grass_variation = function(pos)
|
||||
minetest.swap_node(right_here, {name="dryplants:grass_short"})
|
||||
end
|
||||
|
||||
pl.register_on_generate({
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
"default:dirt_with_grass",
|
||||
},
|
||||
noise_params = pl.generate_noise_params({max_count = 4800, rarity = 25}),
|
||||
"default:dirt_with_grass",
|
||||
},
|
||||
max_count = 4800,
|
||||
rarity = 25,
|
||||
min_elevation = 1, -- above sea level
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
"dryplants:grass",
|
||||
abstract_dryplants.grow_grass_variation
|
||||
)
|
||||
|
@ -7,23 +7,24 @@
|
||||
-- Looked at code from: default
|
||||
-----------------------------------------------------------------------------------------------
|
||||
|
||||
minetest.register_decoration({
|
||||
decoration = {
|
||||
"default:grass_1",
|
||||
biome_lib.register_on_generate(
|
||||
{
|
||||
surface = {
|
||||
"default:dirt_with_grass",
|
||||
"stoneage:grass_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
max_count = TALL_GRASS_PER_MAPBLOCK,
|
||||
rarity = 101 - TALL_GRASS_RARITY,
|
||||
min_elevation = 1, -- above sea level
|
||||
plantlife_limit = -0.9,
|
||||
check_air = true,
|
||||
},
|
||||
{ "default:grass_1",
|
||||
"default:grass_2",
|
||||
"default:grass_3",
|
||||
"default:grass_4",
|
||||
"default:grass_5"
|
||||
},
|
||||
place_on = {
|
||||
"default:dirt_with_grass",
|
||||
"stoneage:grass_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
noise_params = pl.generate_noise_params({max_count = TALL_GRASS_PER_MAPBLOCK, rarity = 101 - TALL_GRASS_RARITY}),
|
||||
flags = "all_floors",
|
||||
deco_type = "simple",
|
||||
y_min = 1,
|
||||
y_max = 48
|
||||
})
|
||||
}
|
||||
)
|
||||
|
@ -349,63 +349,66 @@ minetest.register_entity("dryplants:reedmace_water_entity",{
|
||||
-- GENERATE REEDMACE
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- near water or swamp
|
||||
pl.register_on_generate({
|
||||
surface = {
|
||||
"default:dirt_with_grass",
|
||||
"default:desert_sand",
|
||||
"stoneage:grass_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
noise_params = pl.generate_noise_params({max_count = REEDMACE_NEAR_WATER_PER_MAPBLOCK, rarity = 101 - REEDMACE_NEAR_WATER_RARITY}),
|
||||
--rarity = 60,
|
||||
min_elevation = 1, -- above sea level
|
||||
near_nodes = {"default:water_source","sumpf:dirtywater_source","sumpf:sumpf"},
|
||||
near_nodes_size = 2,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
"default:dirt_with_grass",
|
||||
"default:desert_sand",
|
||||
"stoneage:grass_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
"dryplants:reedmace_near_water",
|
||||
abstract_dryplants.grow_reedmace
|
||||
max_count = REEDMACE_NEAR_WATER_PER_MAPBLOCK,
|
||||
rarity = 101 - REEDMACE_NEAR_WATER_RARITY,
|
||||
--rarity = 60,
|
||||
min_elevation = 1, -- above sea level
|
||||
near_nodes = {"default:water_source","sumpf:dirtywater_source","sumpf:sumpf"},
|
||||
near_nodes_size = 2,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
abstract_dryplants.grow_reedmace
|
||||
)
|
||||
-- in water
|
||||
pl.register_on_generate({
|
||||
surface = {
|
||||
"default:dirt",
|
||||
"default:dirt_with_grass",
|
||||
--"default:desert_sand",
|
||||
--"stoneage:grass_with_silex",
|
||||
"stoneage:sand_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
noise_params = pl.generate_noise_params({max_count = REEDMACE_IN_WATER_PER_MAPBLOCK, rarity = 101 - REEDMACE_IN_WATER_RARITY}),
|
||||
--rarity = 35,
|
||||
min_elevation = 0, -- a bit below sea level
|
||||
max_elevation = 0, -- ""
|
||||
near_nodes = {"default:water_source","sumpf:dirtywater_source"},
|
||||
near_nodes_size = 1,
|
||||
near_nodes_count = 1,
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
"default:dirt",
|
||||
"default:dirt_with_grass",
|
||||
--"default:desert_sand",
|
||||
--"stoneage:grass_with_silex",
|
||||
"stoneage:sand_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
"dryplants:reedmace_in_water",
|
||||
abstract_dryplants.grow_reedmace_water
|
||||
max_count = REEDMACE_IN_WATER_PER_MAPBLOCK,
|
||||
rarity = 101 - REEDMACE_IN_WATER_RARITY,
|
||||
--rarity = 35,
|
||||
min_elevation = 0, -- a bit below sea level
|
||||
max_elevation = 0, -- ""
|
||||
near_nodes = {"default:water_source","sumpf:dirtywater_source"},
|
||||
near_nodes_size = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
abstract_dryplants.grow_reedmace_water
|
||||
)
|
||||
-- for oases & tropical beaches & tropical swamps
|
||||
pl.register_on_generate({
|
||||
surface = {
|
||||
"default:sand",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
noise_params = pl.generate_noise_params({max_count = REEDMACE_FOR_OASES_PER_MAPBLOCK, 101 - REEDMACE_FOR_OASES_RARITY}),
|
||||
--rarity = 10,
|
||||
neighbors = {"default:water_source","sumpf:dirtywater_source","sumpf:sumpf"},
|
||||
ncount = 1,
|
||||
min_elevation = 1, -- above sea level
|
||||
near_nodes = {"default:desert_sand","sumpf:sumpf"},
|
||||
near_nodes_size = 2,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
"default:sand",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
"dryplants:reemace_oases",
|
||||
abstract_dryplants.grow_reedmace
|
||||
max_count = REEDMACE_FOR_OASES_PER_MAPBLOCK,
|
||||
rarity = 101 - REEDMACE_FOR_OASES_RARITY,
|
||||
--rarity = 10,
|
||||
neighbors = {"default:water_source","sumpf:dirtywater_source","sumpf:sumpf"},
|
||||
ncount = 1,
|
||||
min_elevation = 1, -- above sea level
|
||||
near_nodes = {"default:desert_sand","sumpf:sumpf"},
|
||||
near_nodes_size = 2,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
abstract_dryplants.grow_reedmace
|
||||
)
|
||||
|
@ -2,13 +2,6 @@
|
||||
-- Idea by Sokomine
|
||||
-- Code & textures by Mossmanikin
|
||||
|
||||
abstract_molehills = {}
|
||||
|
||||
local molehills_rarity = tonumber(minetest.settings:get("molehills_rarity")) or 99.5
|
||||
local molehills_rarity_fertility = tonumber(minetest.settings:get("molehills_rarity_fertility")) or 1
|
||||
local molehills_fertility = tonumber(minetest.settings:get("molehills_fertility")) or -0.6
|
||||
|
||||
|
||||
-- support for i18n
|
||||
local S = minetest.get_translator("molehills")
|
||||
-----------------------------------------------------------------------------------------------
|
||||
@ -48,28 +41,18 @@ minetest.register_craft({ -- molehills --> dirt
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- GeNeRaTiNG
|
||||
-----------------------------------------------------------------------------------------------
|
||||
abstract_molehills.place_molehill = function(pos)
|
||||
local right_here = {x=pos.x , y=pos.y+1, z=pos.z }
|
||||
if minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z }).name ~= "air"
|
||||
and minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z }).name ~= "air"
|
||||
and minetest.get_node({x=pos.x , y=pos.y, z=pos.z+1}).name ~= "air"
|
||||
and minetest.get_node({x=pos.x , y=pos.y, z=pos.z-1}).name ~= "air"
|
||||
and minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z+1}).name ~= "air"
|
||||
and minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z-1}).name ~= "air"
|
||||
and minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z+1}).name ~= "air"
|
||||
and minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z-1}).name ~= "air" then
|
||||
minetest.swap_node(right_here, {name="molehills:molehill"})
|
||||
end
|
||||
end
|
||||
|
||||
pl.register_on_generate({
|
||||
surface = {"default:dirt_with_grass"},
|
||||
noise_params = pl.generate_noise_params({rarity = molehills_rarity, rarity_fertility = molehills_rarity_fertility}),
|
||||
min_elevation = 1,
|
||||
max_elevation = 40,
|
||||
avoid_nodes = {"group:tree","group:liquid","group:stone","group:falling_node"},
|
||||
avoid_radius = 4,
|
||||
minetest.register_decoration({
|
||||
decoration = {
|
||||
"molehills:molehill"
|
||||
},
|
||||
"molehills:molehills",
|
||||
abstract_molehills.place_molehill
|
||||
)
|
||||
fill_ratio = 0.002,
|
||||
y_min = 1,
|
||||
y_max = 40,
|
||||
place_on = {
|
||||
"default:dirt_with_grass"
|
||||
},
|
||||
spawn_by = "air",
|
||||
num_spawn_by = 3,
|
||||
deco_type = "simple",
|
||||
flags = "all_floors",
|
||||
})
|
||||
|
@ -1,2 +1,2 @@
|
||||
name = molehills
|
||||
depends = default, biome_lib
|
||||
depends = default
|
||||
|
@ -1,8 +0,0 @@
|
||||
#Molehills rarity %
|
||||
molehills_rarity (Molehills rarity %) float 99.5 0 100
|
||||
|
||||
#How much the rarity is reduced by fertility %
|
||||
molehills_rarity_fertility (Molehills rarity fertility reduction %) float 1 0 100
|
||||
|
||||
#Molehills minimum fertility (-1 to +1)
|
||||
molehills_fertility (Molehills minimum fertility) float -0.6 -1 1
|
@ -56,16 +56,16 @@ for i in ipairs(algae_list) do
|
||||
local above_node = minetest.get_node(pt.above)
|
||||
local top_node = minetest.get_node(top_pos)
|
||||
|
||||
if pl.get_nodedef_field(under_node.name, "buildable_to") then
|
||||
if biome_lib.get_nodedef_field(under_node.name, "buildable_to") then
|
||||
if under_node.name ~= "default:water_source" then
|
||||
place_pos = pt.under
|
||||
elseif top_node.name ~= "default:water_source"
|
||||
and pl.get_nodedef_field(top_node.name, "buildable_to") then
|
||||
and biome_lib.get_nodedef_field(top_node.name, "buildable_to") then
|
||||
place_pos = top_pos
|
||||
else
|
||||
return
|
||||
end
|
||||
elseif pl.get_nodedef_field(above_node.name, "buildable_to") then
|
||||
elseif biome_lib.get_nodedef_field(above_node.name, "buildable_to") then
|
||||
place_pos = pt.above
|
||||
end
|
||||
if not place_pos then return end -- something went wrong :P
|
||||
@ -92,7 +92,7 @@ for i in ipairs(algae_list) do
|
||||
minetest.swap_node(place_pos, {name = "flowers:seaweed", param2 = fdir})
|
||||
end
|
||||
|
||||
if not pl.expect_infinite_stacks then
|
||||
if not biome_lib.expect_infinite_stacks then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
|
@ -1,167 +0,0 @@
|
||||
pl = {}
|
||||
local deco = {}
|
||||
|
||||
dofile(minetest.get_modpath("plantlife_lib") .. DIR_DELIM .. "util.lua")
|
||||
|
||||
function pl.get_def_from_id(id)
|
||||
for i, _ in ipairs(deco) do
|
||||
if deco[i][1].id and deco[i][1].id == id then
|
||||
return deco[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function pl.register_on_generate(def, plantname, func)
|
||||
local deco_def = {
|
||||
name = plantname,
|
||||
deco_type = "simple",
|
||||
place_on = def.place_on or def.surface,
|
||||
sidelen = 16,
|
||||
fill_ratio = def.fill_ratio or 0.02,
|
||||
noise_params = def.noise_params,
|
||||
y_min = def.min_elevation,
|
||||
y_max = def.max_elevation,
|
||||
flags = def.flags,
|
||||
decoration = "air", -- spawn the decoration later
|
||||
}
|
||||
-- handle avoid_nodes (no engine support :\)
|
||||
if def.avoid_nodes then
|
||||
deco_def.avoid_nodes = def.avoid_nodes
|
||||
if def.avoid_radius then
|
||||
deco_def.avoid_radius = def.avoid_radius
|
||||
end
|
||||
end
|
||||
-- handle near_nodes (we can't use the engine function for that)
|
||||
if def.near_nodes then
|
||||
deco_def.near_nodes = def.near_nodes
|
||||
if def.near_nodes_size then
|
||||
deco_def.near_nodes_size = def.near_nodes_size
|
||||
if def.near_nodes_vertical then
|
||||
deco_def.near_nodes_vertical = def.near_nodes_vertical
|
||||
end
|
||||
end
|
||||
deco_def.near_nodes_count = def.near_nodes_count or 1
|
||||
end
|
||||
-- handle ncount/neighbors
|
||||
if def.ncount and def.neighbors then
|
||||
deco_def.ncount = def.ncount
|
||||
deco_def.neighbors = def.neighbors
|
||||
end
|
||||
-- save def
|
||||
local next = #deco + 1
|
||||
deco[next] = {}
|
||||
deco[next][1] = deco_def
|
||||
deco[next][2] = func or nil
|
||||
minetest.register_decoration(deco_def)
|
||||
-- print(dump(deco))
|
||||
end
|
||||
|
||||
local ids = {}
|
||||
minetest.register_on_mods_loaded(function()
|
||||
-- print(dump(deco))
|
||||
for k, v in ipairs(deco) do
|
||||
local id = minetest.get_decoration_id(deco[k][1].name)
|
||||
deco[k][1].id = id
|
||||
table.insert(ids, id)
|
||||
end
|
||||
print(dump2(ids))
|
||||
minetest.set_gen_notify("decoration", ids)
|
||||
-- print(dump(deco))
|
||||
end)
|
||||
|
||||
local function place_handler(t)
|
||||
local def = pl.get_def_from_id(t.id)
|
||||
|
||||
-- ncount/neighbors handler
|
||||
if def.ncount and
|
||||
#minetest.find_nodes_in_area(
|
||||
{x = t.pos.x-1, y = t.pos.y, z = t.pos.z-1},
|
||||
{x = t.pos.x+1, y = t.pos.y, z = t.pos.z+1},
|
||||
def.neighbors
|
||||
) <= def.ncount then
|
||||
print("return due ncount")
|
||||
return -- Not enough similar biome nodes around
|
||||
end
|
||||
|
||||
-- near nodes handler
|
||||
if def.near_nodes and
|
||||
#minetest.find_nodes_in_area(
|
||||
{x = t.pos.x-def.near_nodes_size, y = t.pos.y-def.near_nodes_vertical, z = t.pos.z-def.near_nodes_size},
|
||||
{x = t.pos.x+def.near_nodes_size, y = t.pos.y+def.near_nodes_vertical, z = t.pos.z+def.near_nodes_size},
|
||||
def.near_nodes
|
||||
) < def.near_nodes_count then
|
||||
return -- Long distance neighbors do not match
|
||||
end
|
||||
|
||||
-- avoid nodes handler
|
||||
if def.avoid_nodes and def.avoid_radius then
|
||||
local p_top = {x = t.pos.x, y = t.pos.y + 1, z = t.pos.z}
|
||||
if minetest.find_node_near(p_top, def.avoid_radius + math.random(-1.5,2), def.avoid_nodes) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- run spawn function
|
||||
local spawn_func = def[2]
|
||||
spawn_func(t.pos)
|
||||
|
||||
-- some fun
|
||||
local player = minetest.get_player_by_name("Niklp")
|
||||
-- player:set_pos(t.pos)
|
||||
t.pos.y = t.pos.y + 3
|
||||
minetest.add_particle({
|
||||
pos = t.pos,
|
||||
expirationtime = 15,
|
||||
playername = player:get_player_name(),
|
||||
glow = minetest.LIGHT_MAX,
|
||||
texture = "default_mese_crystal.png",
|
||||
size = 15,
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
local t0 = minetest.get_us_time()
|
||||
local g = minetest.get_mapgen_object("gennotify")
|
||||
local locations = {}
|
||||
for _, id in ipairs(ids) do
|
||||
local deco_locations = g["decoration#" .. id] or {}
|
||||
-- print("dl: " .. dump2(deco_locations))
|
||||
for k, pos in pairs(deco_locations) do
|
||||
-- print(id)
|
||||
local next = #locations + 1
|
||||
locations[next] = {}
|
||||
locations[next].pos = pos
|
||||
locations[next].id = id
|
||||
-- dbg() ^ - This must be ID!
|
||||
end
|
||||
end
|
||||
if #locations == 0 then return end
|
||||
-- print("locations: " .. dump2(locations))
|
||||
for _, t in ipairs(locations) do
|
||||
place_handler(t)
|
||||
end
|
||||
local t1 = minetest.get_us_time()
|
||||
print((t1 - t0) / 1000 .. " ms")
|
||||
end)
|
||||
|
||||
--[[ Example plant
|
||||
{
|
||||
{
|
||||
y_min = 1,
|
||||
decoration = "air",
|
||||
deco_type = "simple",
|
||||
id = 45,
|
||||
name = "bushes:bushes_1",
|
||||
place_on = {
|
||||
"default:dirt_with_grass",
|
||||
"stoneage:grass_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
sidelen = 16,
|
||||
fill_ratio = 0.001
|
||||
},
|
||||
^ - decoration def; object ID
|
||||
<function>
|
||||
}, ^ - spawn function
|
||||
]]--
|
@ -1,2 +0,0 @@
|
||||
name = plantlife_lib
|
||||
optional_depends = dbg
|
@ -1,42 +0,0 @@
|
||||
-- Biome lib util functions
|
||||
|
||||
function pl.get_nodedef_field(nodename, fieldname)
|
||||
if not minetest.registered_nodes[nodename] then
|
||||
return nil
|
||||
end
|
||||
return minetest.registered_nodes[nodename][fieldname]
|
||||
end
|
||||
|
||||
if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
|
||||
pl.expect_infinite_stacks = false
|
||||
else
|
||||
pl.expect_infinite_stacks = true
|
||||
end
|
||||
|
||||
-- Noise param helper
|
||||
local function set_defaults(biome)
|
||||
biome.seed_diff = biome.seed_diff or 0
|
||||
biome.rarity = biome.rarity or 50
|
||||
biome.rarity_fertility = biome.rarity_fertility or 0
|
||||
biome.max_count = biome.max_count or 125
|
||||
|
||||
return biome
|
||||
end
|
||||
|
||||
function pl.generate_noise_params(b)
|
||||
local biome = set_defaults(b)
|
||||
local r = (100-biome.rarity)/100
|
||||
local mc = math.min(biome.max_count, 6400)/6400
|
||||
|
||||
local noise_params = {
|
||||
octaves = biome_lib.fertile_perlin_octaves,
|
||||
persist = biome_lib.fertile_perlin_persistence * (100/biome_lib.fertile_perlin_scale),
|
||||
scale = math.min(r, mc),
|
||||
seed = biome.seed_diff,
|
||||
offset = 0,
|
||||
spread = {x = 100, y = 100, z = 100},
|
||||
lacunarity = 2,
|
||||
flags = "absvalue"
|
||||
}
|
||||
return noise_params
|
||||
end
|
@ -152,33 +152,35 @@ abstract_trunks.place_twig = function(pos)
|
||||
end
|
||||
|
||||
if Twigs_on_ground == true then
|
||||
pl.register_on_generate({
|
||||
biome_lib.register_on_generate({
|
||||
surface = {"default:dirt_with_grass"},
|
||||
noise_params = pl.generate_noise_params({max_count = Twigs_on_ground_Max_Count, rarity = Twigs_on_ground_Rarity}),
|
||||
max_count = Twigs_on_ground_Max_Count,
|
||||
rarity = Twigs_on_ground_Rarity,
|
||||
min_elevation = 1,
|
||||
max_elevation = 40,
|
||||
near_nodes = {"group:tree","ferns:fern_03","ferns:fern_02","ferns:fern_01"},
|
||||
near_nodes_size = 3,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
"trunks:on_grass",
|
||||
abstract_trunks.place_twig
|
||||
)
|
||||
end
|
||||
|
||||
if Twigs_on_water == true then
|
||||
pl.register_on_generate({
|
||||
biome_lib.register_on_generate({
|
||||
surface = {"default:water_source"},
|
||||
noise_params = pl.generate_noise_params({max_count = Twigs_on_water_Max_Count, rarity = Twigs_on_water_Rarity}),
|
||||
max_count = Twigs_on_water_Max_Count,
|
||||
rarity = Twigs_on_water_Rarity,
|
||||
min_elevation = 1,
|
||||
max_elevation = 40,
|
||||
near_nodes = {"group:tree"},
|
||||
near_nodes_size = 3,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
"trunks:on_water",
|
||||
abstract_trunks.place_twig
|
||||
)
|
||||
end
|
||||
@ -320,9 +322,10 @@ abstract_trunks.place_trunk = function(pos)
|
||||
end
|
||||
end
|
||||
|
||||
pl.register_on_generate({
|
||||
biome_lib.register_on_generate({
|
||||
surface = {"default:dirt_with_grass"},
|
||||
noise_params = pl.generate_noise_params({max_count = Trunks_Max_Count, rarity = Trunks_Rarity}),
|
||||
max_count = Trunks_Max_Count, -- 320,
|
||||
rarity = Trunks_Rarity, -- 99,
|
||||
min_elevation = 1,
|
||||
max_elevation = 40,
|
||||
avoid_nodes = {"group:tree"},
|
||||
@ -331,8 +334,8 @@ pl.register_on_generate({
|
||||
near_nodes_size = 3,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
"trunks:on_grass_2",
|
||||
abstract_trunks.place_trunk
|
||||
)
|
||||
|
||||
@ -353,9 +356,10 @@ abstract_trunks.grow_moss_on_ground = function(pos)
|
||||
|
||||
end
|
||||
|
||||
pl.register_on_generate({
|
||||
biome_lib.register_on_generate({
|
||||
surface = {"default:dirt_with_grass"},
|
||||
noise_params = pl.generate_noise_params({max_count = Moss_on_ground_Max_Count, rarity = Moss_on_ground_Rarity}),
|
||||
max_count = Moss_on_ground_Max_Count,
|
||||
rarity = Moss_on_ground_Rarity,
|
||||
min_elevation = 1,
|
||||
max_elevation = 40,
|
||||
near_nodes = {
|
||||
@ -367,8 +371,8 @@ pl.register_on_generate({
|
||||
near_nodes_size = 2,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
"trunks:on_grass_3",
|
||||
abstract_trunks.grow_moss_on_ground
|
||||
)
|
||||
end
|
||||
@ -433,8 +437,8 @@ abstract_trunks.grow_moss_on_trunk = function(pos)
|
||||
--end
|
||||
end
|
||||
|
||||
pl.register_on_generate({
|
||||
surface = {
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
"default:tree",
|
||||
"default:jungletree",
|
||||
"default:pine_tree",
|
||||
@ -454,12 +458,14 @@ pl.register_on_generate({
|
||||
"moretrees:willow_trunk",
|
||||
"default:mossycobble"
|
||||
},
|
||||
noise_params = pl.generate_noise_params({max_count = Moss_on_trunk_Max_Count, rarity = Moss_on_trunk_Rarity}),
|
||||
max_count = Moss_on_trunk_Max_Count,
|
||||
rarity = Moss_on_trunk_Rarity,
|
||||
min_elevation = 1,
|
||||
max_elevation = 40,
|
||||
plantlife_limit = -0.9,
|
||||
check_air = false,
|
||||
},
|
||||
"trunks:moss_on_trunk",
|
||||
abstract_trunks.grow_moss_on_trunk
|
||||
"abstract_trunks.grow_moss_on_trunk"
|
||||
)
|
||||
end
|
||||
|
||||
@ -504,18 +510,20 @@ abstract_trunks.grow_roots = function(pos)
|
||||
end
|
||||
end
|
||||
|
||||
pl.register_on_generate({
|
||||
biome_lib.register_on_generate({
|
||||
surface = {"group:tree"},
|
||||
noise_params = pl.generate_noise_params({max_count = 1000, rarity = 1,}),
|
||||
max_count = 1000,
|
||||
rarity = 1,
|
||||
min_elevation = 1,
|
||||
max_elevation = 40,
|
||||
near_nodes = {"default:dirt_with_grass"},
|
||||
near_nodes_size = 1,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -1,
|
||||
check_air = false,
|
||||
},
|
||||
"trunks:grow_roots",
|
||||
abstract_trunks.grow_roots
|
||||
"abstract_trunks.grow_roots"
|
||||
)
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user