Dig upwards for papyrus and cactus
authorCasimir <jul.lutz@gmx.net>
Mon, 2 Dec 2013 18:23:29 +0000 (19:23 +0100)
committerBlockMen <nmuelll@web.de>
Sat, 5 Jul 2014 13:56:07 +0000 (15:56 +0200)
mods/default/functions.lua
mods/default/nodes.lua

index 4f5f85d48c135aa92637c92f078bb012c7fe1b69..6840c5d24219c865068d930a47dc2b1b3bb1b2c7 100644 (file)
@@ -266,6 +266,19 @@ minetest.register_abm({
        end,
 })
 
+--
+-- dig upwards
+--
+
+function default.dig_up(pos, node, digger)
+       if digger == nil then return end
+       local np = {x = pos.x, y = pos.y + 1, z = pos.z}
+       local nn = minetest.get_node(np)
+       if nn.name == node.name then
+               minetest.node_dig(np, nn, digger)
+       end
+end
+
 --
 -- Leafdecay
 --
index 9f541deb29a9a36e654d864dc53d345df2e47dc5..3a7d63b777c9a652cd94247d7c2162756969cb37 100644 (file)
@@ -349,7 +349,10 @@ minetest.register_node("default:cactus", {
        is_ground_content = true,
        groups = {snappy=1,choppy=3,flammable=2},
        sounds = default.node_sound_wood_defaults(),
-       on_place = minetest.rotate_node
+       on_place = minetest.rotate_node,
+       after_dig_node = function(pos, node, metadata, digger)
+               default.dig_up(pos, node, digger)
+       end,
 })
 
 minetest.register_node("default:papyrus", {
@@ -367,6 +370,9 @@ minetest.register_node("default:papyrus", {
        },
        groups = {snappy=3,flammable=2},
        sounds = default.node_sound_leaves_defaults(),
+       after_dig_node = function(pos, node, metadata, digger)
+               default.dig_up(pos, node, digger)
+       end,
 })
 
 minetest.register_node("default:bookshelf", {