summaryrefslogtreecommitdiff
path: root/leafdecay.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2013-10-27 02:05:44 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2013-10-27 02:05:44 -0400
commitf3a8c29d1a06ffe520d424ae1a7dde8df282e851 (patch)
tree09be716317f8061bef3975ca89ab14a8aa0ad5e2 /leafdecay.lua
parentfa64297c0916d11ce0f4ad23fba08a8e1f4d8bd3 (diff)
Fixed missing drops on leaf decay
Diffstat (limited to 'leafdecay.lua')
-rw-r--r--leafdecay.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/leafdecay.lua b/leafdecay.lua
index e2780ad..f1b8021 100644
--- a/leafdecay.lua
+++ b/leafdecay.lua
@@ -9,6 +9,21 @@ function clone_node(name)
return node2
end
+-- this function is based on the default leafdecay code
+local process_drops = function(pos, name)
+ local drops = minetest.get_node_drops(name)
+ for _,dropitem in ipairs(drops) do
+ if dropitem ~= name then
+ local newpos = {
+ x=pos.x + math.random(0, 0.5),
+ y=pos.y + math.random(0, 0.5),
+ z=pos.z + math.random(0, 0.5)
+ }
+ minetest.add_item(newpos, dropitem)
+ end
+ end
+end
+
if moretrees.enable_leafdecay then
for i in ipairs(moretrees.treelist) do
local treename = moretrees.treelist[i][1]
@@ -20,6 +35,7 @@ if moretrees.enable_leafdecay then
action = function(pos, node, active_object_count, active_object_count_wider)
if minetest.find_node_near(pos, moretrees.leafdecay_radius, "moretrees:"..treename.."_trunk") then return end
if minetest.find_node_near(pos, moretrees.leafdecay_radius, "ignore") then return end
+ process_drops(pos, node.name)
minetest.remove_node(pos)
nodeupdate(pos)
end
@@ -34,6 +50,7 @@ if moretrees.enable_leafdecay then
action = function(pos, node, active_object_count, active_object_count_wider)
if minetest.find_node_near(pos, moretrees.leafdecay_radius, {"default:jungletree", "moretrees:jungletree_trunk"}) then return end
if minetest.find_node_near(pos, moretrees.leafdecay_radius, "ignore") then return end
+ process_drops(pos, node.name)
minetest.remove_node(pos)
nodeupdate(pos)
end
@@ -46,6 +63,7 @@ if moretrees.enable_leafdecay then
action = function(pos, node, active_object_count, active_object_count_wider)
if minetest.find_node_near(pos, moretrees.leafdecay_radius, "moretrees:fir_trunk") then return end
if minetest.find_node_near(pos, moretrees.leafdecay_radius, "ignore") then return end
+ process_drops(pos, node.name)
minetest.remove_node(pos)
nodeupdate(pos)
end
@@ -58,6 +76,7 @@ if moretrees.enable_leafdecay then
action = function(pos, node, active_object_count, active_object_count_wider)
if minetest.find_node_near(pos, moretrees.palm_leafdecay_radius, "moretrees:palm_trunk") then return end
if minetest.find_node_near(pos, moretrees.palm_leafdecay_radius, "ignore") then return end
+ process_drops(pos, node.name)
minetest.remove_node(pos)
nodeupdate(pos)
end
@@ -77,6 +96,7 @@ if moretrees.enable_default_leafdecay then
action = function(pos, node, active_object_count, active_object_count_wider)
if minetest.find_node_near(pos, moretrees.default_leafdecay_radius, "default:tree") then return end
if minetest.find_node_near(pos, moretrees.default_leafdecay_radius, "ignore") then return end
+ process_drops(pos, node.name)
minetest.remove_node(pos)
nodeupdate(pos)
end
@@ -96,6 +116,7 @@ if moretrees.enable_default_jungle_leafdecay then
action = function(pos, node, active_object_count, active_object_count_wider)
if minetest.find_node_near(pos, moretrees.default_jungle_leafdecay_radius, "default:jungletree") then return end
if minetest.find_node_near(pos, moretrees.default_jungle_leafdecay_radius, "ignore") then return end
+ process_drops(pos, node.name)
minetest.remove_node(pos)
nodeupdate(pos)
end