summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.lua69
-rw-r--r--leafdecay.lua44
-rw-r--r--node_defs.lua21
-rw-r--r--settings.lua9
4 files changed, 85 insertions, 58 deletions
diff --git a/init.lua b/init.lua
index 9c63d7a..936c1d0 100644
--- a/init.lua
+++ b/init.lua
@@ -36,6 +36,7 @@ dofile(minetest.get_modpath("moretrees").."/node_defs.lua")
dofile(minetest.get_modpath("moretrees").."/tree_models.lua")
dofile(minetest.get_modpath("moretrees").."/biome_defs.lua")
dofile(minetest.get_modpath("moretrees").."/crafts.lua")
+dofile(minetest.get_modpath("moretrees").."/leafdecay.lua")
-- tree spawning setup
@@ -54,9 +55,6 @@ plantslib:register_generate_plant(moretrees.fir_biome, "moretrees:grow_fir")
-- sapling growth
-local sapling_interval = 500
-local sapling_chance = 20
-
for i in ipairs(moretrees.simple_trees) do
local tree_name = trees[i][1]
local tree_model = tree_name.."_model"
@@ -65,8 +63,8 @@ for i in ipairs(moretrees.simple_trees) do
plantslib:dbg(dump(moretrees[tree_biome].surface))
plantslib:grow_plants({
- grow_delay = sapling_interval,
- grow_chance = sapling_chance,
+ grow_delay = moretrees.sapling_interval,
+ grow_chance = moretrees.sapling_chance,
grow_plant = "moretrees:"..tree_name.."_sapling",
grow_nodes = moretrees[tree_biome].surface,
grow_function = moretrees[tree_model],
@@ -74,32 +72,32 @@ for i in ipairs(moretrees.simple_trees) do
end
plantslib:grow_plants({
- grow_delay = sapling_interval,
- grow_chance = sapling_chance,
+ grow_delay = moretrees.sapling_interval,
+ grow_chance = moretrees.sapling_chance,
grow_plant = "moretrees:birch_sapling",
grow_nodes = moretrees.birch_biome.surface,
grow_function = "moretrees:grow_birch"
})
plantslib:grow_plants({
- grow_delay = sapling_interval,
- grow_chance = sapling_chance,
+ grow_delay = moretrees.sapling_interval,
+ grow_chance = moretrees.sapling_chance,
grow_plant = "moretrees:spruce_sapling",
grow_nodes = moretrees.spruce_biome.surface,
grow_function = "moretrees:grow_spruce"
})
plantslib:grow_plants({
- grow_delay = sapling_interval,
- grow_chance = sapling_chance,
+ grow_delay = moretrees.sapling_interval,
+ grow_chance = moretrees.sapling_chance,
grow_plant = "moretrees:fir_sapling",
grow_nodes = moretrees.fir_biome.surface,
grow_function = "moretrees:grow_fir"
})
plantslib:grow_plants({
- grow_delay = sapling_interval,
- grow_chance = sapling_chance,
+ grow_delay = moretrees.sapling_interval,
+ grow_chance = moretrees.sapling_chance,
grow_plant = "moretrees:jungletree_sapling",
grow_nodes = moretrees.jungletree_biome.surface,
grow_function = "moretrees:grow_jungletree"
@@ -226,49 +224,4 @@ if moretrees.firs_remove_default_trees == true then
})
end
--- leaf decay
-
-minetest.register_abm({
- nodenames = moretrees.leaves_list,
- 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, moretrees.leafdecay_radius, moretrees.trunks_list) then
- minetest.env:remove_node(pos)
- minetest.env:dig_node(pos)
- end
- end
-})
-
-minetest.register_abm({
- nodenames = "moretrees:palm_leaves",
- 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, 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/leafdecay.lua b/leafdecay.lua
new file mode 100644
index 0000000..cab0281
--- /dev/null
+++ b/leafdecay.lua
@@ -0,0 +1,44 @@
+-- leaf decay
+
+minetest.register_abm({
+ nodenames = moretrees.leaves_list,
+ 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, moretrees.leafdecay_radius, moretrees.trunks_list) then
+ minetest.env:remove_node(pos)
+ minetest.env:dig_node(pos)
+ end
+ end
+})
+
+minetest.register_abm({
+ nodenames = "moretrees:palm_leaves",
+ 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, 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
diff --git a/node_defs.lua b/node_defs.lua
index e8f0ba9..858f5af 100644
--- a/node_defs.lua
+++ b/node_defs.lua
@@ -186,6 +186,27 @@ minetest.register_node("moretrees:fir_leaves_bright", {
})
table.insert(moretrees.leaves_list, "moretrees:fir_leaves_bright")
+if moretrees.enable_redefine_apple then
+ minetest.register_node(":default:apple", {
+ description = "Apple",
+ drawtype = "plantlike",
+ visual_scale = 1.0,
+ tiles = {"default_apple.png"},
+ inventory_image = "default_apple.png",
+ paramtype = "light",
+ sunlight_propagates = true,
+ walkable = false,
+ selection_box = {
+ type = "fixed",
+ fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
+ },
+ groups = {fleshy=3,dig_immediate=3,flammable=2,attached_node=1},
+ on_use = minetest.item_eat(4),
+ sounds = default.node_sound_defaults(),
+ })
+end
+
+
-- Backward compatbility with old mods/nodes:
diff --git a/settings.lua b/settings.lua
index 0da6be3..f9974ef 100644
--- a/settings.lua
+++ b/settings.lua
@@ -12,6 +12,11 @@ moretrees.enable_replace_default_trees = false
moretrees.enable_default_leafdecay = false
+-- Enable this if you want moretrees to redefine default apples so that they
+-- fall when leaves decay/are dug.
+
+moretrees.enable_redefine_apple = true
+
-- various settings to configure leaf decay in general.
moretrees.leafdecay_delay = 2
@@ -31,3 +36,7 @@ moretrees.firs_remove_default_trees = false
moretrees.firs_remove_interval = 2
moretrees.firs_remove_chance = 150
+-- Sapling settings
+
+moretrees.sapling_interval = 500
+moretrees.sapling_chance = 20