Created
April 17, 2013 12:27
-
-
Save celeron55/5403850 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 8dfe2b83d7c447b7a4da1b16affeab2602610194 Mon Sep 17 00:00:00 2001 | |
From: "0gb.us" <0gb.us@0gb.us> | |
Date: Thu, 4 Apr 2013 21:57:49 -0700 | |
Subject: [PATCH] Add leaf decay preservation option. | |
As suggested by PilzAdam, nodes with a leaf decay rating of one will function as before, but nodes with a leaf decay rating of two will drop the decayed node. | |
As discussed at http://forum.minetest.net/viewtopic.php?pid=80182#p80182 , this could be used for apple decay. | |
--- | |
mods/default/leafdecay.lua | 7 ++++++- | |
1 file changed, 6 insertions(+), 1 deletion(-) | |
diff --git a/mods/default/leafdecay.lua b/mods/default/leafdecay.lua | |
index 330bb33..df92b7d 100644 | |
--- a/mods/default/leafdecay.lua | |
+++ b/mods/default/leafdecay.lua | |
@@ -29,10 +29,15 @@ minetest.register_abm({ | |
action = function(p0, node, _, _) | |
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")") | |
local do_preserve = false | |
+ local nodrop | |
local d = minetest.registered_nodes[node.name].groups.leafdecay | |
if not d or d == 0 then | |
--print("not groups.leafdecay") | |
return | |
+ elseif d == 1 | |
+ nodrop = node.name | |
+ else | |
+ nodrop = "" | |
end | |
local n0 = minetest.env:get_node(p0) | |
if n0.param2 ~= 0 then | |
@@ -75,7 +80,7 @@ minetest.register_abm({ | |
-- Drop stuff other than the node itself | |
itemstacks = minetest.get_node_drops(n0.name) | |
for _, itemname in ipairs(itemstacks) do | |
- if itemname ~= n0.name then | |
+ if itemname ~= nodrop then | |
local p_drop = { | |
x = p0.x - 0.5 + math.random(), | |
y = p0.y - 0.5 + math.random(), | |
-- | |
1.8.1.5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment