2013-02-11 18:23:05 +01:00
|
|
|
-- leaf decay
|
|
|
|
|
2013-02-12 04:07:40 +01:00
|
|
|
if moretrees.enable_leafdecay then
|
|
|
|
for i in ipairs(moretrees.treelist) do
|
|
|
|
local treename = moretrees.treelist[i][1]
|
|
|
|
if treename ~= "jungletree" and treename ~= "fir" then
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = "moretrees:"..treename.."_leaves",
|
|
|
|
interval = moretrees.leafdecay_delay,
|
|
|
|
chance = moretrees.leafdecay_chance,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2013-07-01 05:55:07 +02:00
|
|
|
if not minetest.find_node_near(pos, moretrees.leafdecay_radius, "moretrees:"..treename.."_trunk") then
|
|
|
|
minetest.remove_node(pos)
|
2013-04-08 04:09:18 +02:00
|
|
|
nodeupdate(pos)
|
2013-02-12 04:07:40 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
2013-02-11 18:23:05 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-12 04:07:40 +01:00
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"moretrees:jungletree_leaves_red","moretrees:jungletree_leaves_green","moretrees:jungletree_leaves_yellow"},
|
|
|
|
interval = moretrees.leafdecay_delay,
|
|
|
|
chance = moretrees.leafdecay_chance,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2013-07-01 05:55:07 +02:00
|
|
|
if not minetest.find_node_near(pos, moretrees.leafdecay_radius, {"default:jungletree", "moretrees:jungletree_trunk"}) then
|
|
|
|
minetest.remove_node(pos)
|
2013-04-08 04:09:18 +02:00
|
|
|
nodeupdate(pos)
|
2013-02-12 04:07:40 +01:00
|
|
|
end
|
2013-02-11 18:23:05 +01:00
|
|
|
end
|
2013-02-12 04:07:40 +01:00
|
|
|
})
|
2013-02-11 18:23:05 +01:00
|
|
|
|
2013-02-12 04:07:40 +01:00
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"moretrees:fir_leaves", "moretrees:fir_leaves_bright"},
|
|
|
|
interval = moretrees.leafdecay_delay,
|
|
|
|
chance = moretrees.leafdecay_chance,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2013-07-01 05:55:07 +02:00
|
|
|
if not minetest.find_node_near(pos, moretrees.leafdecay_radius, "moretrees:fir_trunk") then
|
|
|
|
minetest.remove_node(pos)
|
2013-04-08 04:09:18 +02:00
|
|
|
nodeupdate(pos)
|
2013-02-12 04:07:40 +01:00
|
|
|
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)
|
2013-07-01 05:55:07 +02:00
|
|
|
if not minetest.find_node_near(pos, moretrees.palm_leafdecay_radius, "moretrees:palm_trunk") then
|
|
|
|
minetest.remove_node(pos)
|
2013-04-08 04:09:18 +02:00
|
|
|
nodeupdate(pos)
|
2013-02-12 04:07:40 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
2013-02-11 18:23:05 +01:00
|
|
|
|
2013-04-08 04:09:18 +02:00
|
|
|
if moretrees.enable_default_leafdecay then
|
2013-02-11 18:23:05 +01:00
|
|
|
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)
|
2013-07-01 05:55:07 +02:00
|
|
|
if not minetest.find_node_near(pos, moretrees.default_leafdecay_radius, {"default:tree"}) then
|
|
|
|
minetest.remove_node(pos)
|
2013-04-08 04:09:18 +02:00
|
|
|
nodeupdate(pos)
|
2013-02-11 18:23:05 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|