From: Vanessa Ezekowitz Date: Mon, 11 Feb 2013 17:09:17 +0000 (-0500) Subject: Added ability to do leaf decay on default trees, moved several configuration X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=1445263d734eabd017d3af1b57e19dc4e9870545;p=zefram%2Fminetest%2Fmoretrees.git Added ability to do leaf decay on default trees, moved several configuration settings into a separate file. You should disable leaf decay in minetest_game if you enable it here. --- diff --git a/init.lua b/init.lua index 405e75b..9c63d7a 100644 --- a/init.lua +++ b/init.lua @@ -27,8 +27,11 @@ -- -- We'll just save this for possible later use ;-) -- + moretrees = {} +dofile(minetest.get_modpath("moretrees").."/settings.lua") + dofile(minetest.get_modpath("moretrees").."/node_defs.lua") dofile(minetest.get_modpath("moretrees").."/tree_models.lua") dofile(minetest.get_modpath("moretrees").."/biome_defs.lua") @@ -49,16 +52,6 @@ plantslib:register_generate_plant(moretrees.spruce_biome, "moretrees:grow_spruce plantslib:register_generate_plant(moretrees.jungletree_biome, "moretrees:grow_jungletree") plantslib:register_generate_plant(moretrees.fir_biome, "moretrees:grow_fir") --- These three lines replace default trees with beech --- Enable them if you want but be warned - due to serious bugs in the speed --- of the engine's map generator/loader, doing so will slow it WAY down. - ---[[ -minetest.register_alias("mapgen_tree", "air") -minetest.register_alias("mapgen_leaves", "air") -plantslib:register_generate_plant(moretrees.beech_biome, moretrees.beech_model) -]]-- - -- sapling growth local sapling_interval = 500 @@ -214,14 +207,14 @@ end -- Should we remove all the trees above the conifers altitude? -if CONIFERS_REMOVE_TREES == true then +if moretrees.firs_remove_default_trees == true then minetest.register_abm({ nodenames = { "default:tree", "default:leaves" }, - interval = CONIFERS_RTREES_INTERVAL, - chance = CONIFERS_RTREES_CHANCE, + interval = moretrees.firs_remove_interval, + chance = moretrees.firs_remove_chance, action = function(pos, node, _, _) if minetest.env:get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name == "air" @@ -235,17 +228,12 @@ end -- leaf decay -local leafdecay_delay = 2 -local leafdecay_chance = 150 -local leafdecay_radius = 5 -local palms_leafdecay_radius = 8 - minetest.register_abm({ nodenames = moretrees.leaves_list, - interval = leafdecay_delay, - chance = leafdecay_chance, + interval = moretrees.leafdecay_delay, + chance = moretrees.leafdecay_chance, action = function(pos, node, active_object_count, active_object_count_wider) - if not minetest.env:find_node_near(pos, leafdecay_radius, moretrees.trunks_list) then + if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, moretrees.trunks_list) then minetest.env:remove_node(pos) minetest.env:dig_node(pos) end @@ -254,13 +242,33 @@ minetest.register_abm({ minetest.register_abm({ nodenames = "moretrees:palm_leaves", - interval = leafdecay_delay, - chance = leafdecay_chance, + interval = moretrees.leafdecay_delay, + chance = moretrees.leafdecay_chance, action = function(pos, node, active_object_count, active_object_count_wider) - if not minetest.env:find_node_near(pos, palms_leafdecay_radius, moretrees.trunks_list) then + if not minetest.env:find_node_near(pos, moretrees.palm_leafdecay_radius, moretrees.trunks_list) then minetest.env:remove_node(pos) minetest.env:dig_node(pos) end end }) + + +if moretrees.enable_replace_default_trees then + minetest.register_alias("mapgen_tree", "air") + minetest.register_alias("mapgen_leaves", "air") + plantslib:register_generate_plant(moretrees.beech_biome, moretrees.beech_model) +elseif moretrees.enable_default_leafdecay then + minetest.register_abm({ + nodenames = "default:leaves", + interval = moretrees.default_leafdecay_delay, + chance = moretrees.default_leafdecay_chance, + action = function(pos, node, active_object_count, active_object_count_wider) + if not minetest.env:find_node_near(pos, moretrees.default_leafdecay_radius, {"default:tree"}) then + minetest.env:remove_node(pos) + minetest.env:dig_node(pos) + end + end + }) +end + print("[Moretrees] Loaded (2013-01-18)") diff --git a/settings.lua b/settings.lua new file mode 100644 index 0000000..0da6be3 --- /dev/null +++ b/settings.lua @@ -0,0 +1,33 @@ +-- Configuration variables + +-- Enable replacement of default trees with birch if you want but be warned - +-- due to bugs in the speed of the engine's map generator/loader, doing so\ +-- will slow it WAY down. + +moretrees.enable_replace_default_trees = false + +-- Enable the first one if you want this mod's leafdecay code to affect the +-- old default trees. You'll want to manually disable the default leafdecay +-- code in minetest_game if you enable this. + +moretrees.enable_default_leafdecay = false + +-- various settings to configure leaf decay in general. + +moretrees.leafdecay_delay = 2 +moretrees.leafdecay_chance = 150 +moretrees.leafdecay_radius = 5 + +moretrees.palm_leafdecay_radius = 8 + +moretrees.default_leafdecay_delay = 2 +moretrees.default_leafdecay_chance = 50 +moretrees.default_leafdecay_radius = 4 + +-- Change these settings if you want default trees to be gradually cut down +-- above the elevation where firs normally generate. + +moretrees.firs_remove_default_trees = false +moretrees.firs_remove_interval = 2 +moretrees.firs_remove_chance = 150 +