diff --git a/bushes/init.lua b/bushes/init.lua index a24812e..7559cd1 100644 --- a/bushes/init.lua +++ b/bushes/init.lua @@ -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 ) +]]-- \ No newline at end of file diff --git a/bushes/mod.conf b/bushes/mod.conf index 0a4f665..2d54307 100644 --- a/bushes/mod.conf +++ b/bushes/mod.conf @@ -1,3 +1,3 @@ name = bushes -depends = default, biome_lib +depends = default, biome_lib, plantlife_lib optional_depends = stoneage, sumpf diff --git a/plantlife_lib/init.lua b/plantlife_lib/init.lua new file mode 100644 index 0000000..94fab02 --- /dev/null +++ b/plantlife_lib/init.lua @@ -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) \ No newline at end of file diff --git a/plantlife_lib/mod.conf b/plantlife_lib/mod.conf new file mode 100644 index 0000000..97a88bb --- /dev/null +++ b/plantlife_lib/mod.conf @@ -0,0 +1 @@ +name = plantlife_lib \ No newline at end of file