moretrees/leafdecay.lua
Vanessa Ezekowitz 4c198fad78 Multiple changes, see below:
Fix replacement of default trees so that it works correctly.  Beeches
now use default tree nodes, but L-systems models.  This redefines the
default tree, wood, leaves, and saplings so that they use moretrees'
textures "Beech" in their descriptions, but only if replacement of
default trees is enabled.

Added backward-compat aliases for this change.

Moved tree replacement mapgen->air aliases to a more logical spot in the
code.

Also, changed out all leaf decay dig_node() calls for nodeupdate(), since the
former calls the latter anyway, and the latter is what does the job.

Increased the palm leaf decay radius to 12.
2013-04-07 22:09:18 -04:00

71 lines
2.4 KiB
Lua

-- leaf decay
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)
if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, "moretrees:"..treename.."_trunk") then
minetest.env:remove_node(pos)
nodeupdate(pos)
end
end
})
end
end
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)
if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, {"default:jungletree", "moretrees:jungletree_trunk"}) then
minetest.env:remove_node(pos)
nodeupdate(pos)
end
end
})
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)
if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, "moretrees:fir_trunk") then
minetest.env:remove_node(pos)
nodeupdate(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:palm_trunk") then
minetest.env:remove_node(pos)
nodeupdate(pos)
end
end
})
end
if 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)
nodeupdate(pos)
end
end
})
end