Let apples fall when the tree is decaying
authorPilzAdam <pilzadam@minetest.net>
Tue, 21 May 2013 14:44:39 +0000 (16:44 +0200)
committerPilzAdam <pilzadam@minetest.net>
Tue, 21 May 2013 16:50:39 +0000 (18:50 +0200)
mods/default/functions.lua
mods/default/nodes.lua

index c5245f7691bdc48a19ff54632bccd6763118fcef..aa0d4cec41d108947ce15f4783887fd5d6ba3b38 100644 (file)
@@ -216,6 +216,9 @@ minetest.register_abm({
 --
 -- If param2 of the node is ~= 0, the node will always be preserved. Thus, if
 -- the player places a node of that kind, you will want to set param2=1 or so.
+--
+-- If the node is in the leafdecay_drop group then the it will always be dropped
+-- as an item
 
 default.leafdecay_trunk_cache = {}
 default.leafdecay_enable_cache = true
@@ -284,7 +287,8 @@ 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 minetest.get_item_group(n0.name, "leafdecay_drop") ~= 0 or
+                                               itemname ~= n0.name then
                                        local p_drop = {
                                                x = p0.x - 0.5 + math.random(),
                                                y = p0.y - 0.5 + math.random(),
index 26e02ed5f733ebed9a79c98d3dbfc941a1802ff8..e2f81aa4a3d328fe59360621f388dff645dada13 100644 (file)
@@ -1124,9 +1124,14 @@ minetest.register_node("default:apple", {
                type = "fixed",
                fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
        },
-       groups = {fleshy=3,dig_immediate=3,flammable=2},
+       groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=1,leafdecay_drop=1},
        on_use = minetest.item_eat(4),
        sounds = default.node_sound_defaults(),
+       after_place_node = function(pos, placer, itemstack)
+               if placer:is_player() then
+                       minetest.env:set_node(pos, {name="default:apple", param2=1})
+               end
+       end,
 })
 
 minetest.register_node("default:dry_shrub", {