mirror of
https://github.com/mt-mods/plantlife_modpack.git
synced 2024-11-12 13:20:39 +01:00
some biome_lib replacement experiments
This commit is contained in:
parent
577404c850
commit
15f62452b8
|
@ -211,7 +211,7 @@ abstract_bushes.grow_bush_node = function(pos,dir, leaf_type)
|
|||
end
|
||||
|
||||
|
||||
biome_lib.register_on_generate({
|
||||
pl.register_on_generate({
|
||||
surface = {
|
||||
"default:dirt_with_grass",
|
||||
"stoneage:grass_with_silex",
|
||||
|
@ -223,6 +223,8 @@ biome_lib.register_on_generate({
|
|||
plantlife_limit = bushes_bush_fertility,
|
||||
min_elevation = 1, -- above sea level
|
||||
},
|
||||
"bushes:bushes",
|
||||
nil,
|
||||
abstract_bushes.grow_bush
|
||||
)
|
||||
|
||||
|
@ -253,7 +255,7 @@ abstract_bushes.grow_youngtree_node2 = function(pos, height)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
--[[
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
"default:dirt_with_grass",
|
||||
|
@ -268,3 +270,4 @@ biome_lib.register_on_generate({
|
|||
},
|
||||
abstract_bushes.grow_youngtree2
|
||||
)
|
||||
]]--
|
|
@ -1,3 +1,3 @@
|
|||
name = bushes
|
||||
depends = default, biome_lib
|
||||
depends = default, biome_lib, plantlife_lib
|
||||
optional_depends = stoneage, sumpf
|
||||
|
|
51
plantlife_lib/init.lua
Normal file
51
plantlife_lib/init.lua
Normal file
|
@ -0,0 +1,51 @@
|
|||
pl = {}
|
||||
local deco_ids = {}
|
||||
local spawn_funcs = {}
|
||||
|
||||
function pl.register_on_generate(def, plantname, index, func) -- add spawnfunction support
|
||||
if not index then index = 1 end
|
||||
local deco_def = {
|
||||
name = plantname .. "_" .. index,
|
||||
deco_type = "simple",
|
||||
place_on = def.place_on or def.surface,
|
||||
sidelen = 16,
|
||||
fill_ratio = def.fill_ratio or 0.001,
|
||||
y_min = def.min_elevation,
|
||||
y_max = def.max_elevation,
|
||||
spawn_by = def.near_nodes,
|
||||
num_spawn_by = def.near_nodes_count,
|
||||
decoration = "air"
|
||||
}
|
||||
deco_ids[#deco_ids+1] = plantname .. ("_" .. index or "_1")
|
||||
spawn_funcs[#deco_ids+1] = func
|
||||
minetest.register_decoration(deco_def)
|
||||
end
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
print(dump(deco_ids))
|
||||
for k, v in pairs(deco_ids) do
|
||||
deco_ids[k] = minetest.get_decoration_id(v)
|
||||
end
|
||||
minetest.set_gen_notify("decoration", deco_ids)
|
||||
print(dump(deco_ids))
|
||||
end)
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
local g = minetest.get_mapgen_object("gennotify")
|
||||
print(dump(g))
|
||||
local locations = {}
|
||||
for _, id in pairs(deco_ids) do
|
||||
local deco_locations = g["decoration#" .. id] or {}
|
||||
for _, pos in pairs(deco_locations) do
|
||||
locations[#locations+1] = pos
|
||||
end
|
||||
end
|
||||
print(dump(locations))
|
||||
if #locations == 0 then return end
|
||||
for _, pos in ipairs(locations) do
|
||||
print("yay")
|
||||
abstract_bushes.grow_bush(pos)
|
||||
local player = minetest.get_player_by_name("Niklp")
|
||||
player:set_pos(pos)
|
||||
end
|
||||
end)
|
1
plantlife_lib/mod.conf
Normal file
1
plantlife_lib/mod.conf
Normal file
|
@ -0,0 +1 @@
|
|||
name = plantlife_lib
|
Loading…
Reference in New Issue
Block a user