From fe773cd91ace1b3ffb476d34daebf59f38166ee4 Mon Sep 17 00:00:00 2001 From: davedevils Date: Wed, 1 Jul 2015 07:37:51 +0200 Subject: [PATCH] Added Dig_By_Water group --> the water dig and remove the node but drop (if the item drop) --- mods/default/functions.lua | 19 +++++++++++++++++++ mods/default/nodes.lua | 20 ++++++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 6a7d66f90..46f2c3626 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -96,6 +96,25 @@ grow_reeds = function(pos, node) end -- ABMs +minetest.register_abm({ + nodenames = {"group:dig_by_water"}, + neighbors = {"group:water"}, + interval = 1, + chance = 1, + action = function(pos) + local originalpos = pos + for dx=-1,1 do + for dy=-1,1 do + pos.x = pos.x+dx + pos.y = pos.y+dy + if minetest.env:get_node(pos).name == "group:water" then + minetest.env:set_node(pos, {name="default:air"}) + end + end + end + end, +}) + minetest.register_abm({ nodenames = {"default:cactus"}, neighbors = {"group:sand"}, diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index 282a58def..6e51915b0 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -623,7 +623,7 @@ minetest.register_node("default:junglegrass", { buildable_to = true, is_ground_content = true, stack_max = 64, - groups = {snappy=3,flammable=2,attached_node=1}, + groups = {snappy=3,flammable=2,attached_node=1,dig_by_water=1}, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", @@ -1678,7 +1678,7 @@ minetest.register_node("default:grass", { walkable = false, buildable_to = true, is_ground_content = true, - groups = {snappy=3,flammable=3,attached_node=1,dig_immediate=3}, + groups = {snappy=3,flammable=3,attached_node=1,dig_immediate=3,dig_by_water=1}, sounds = default.node_sound_leaves_defaults(), after_dig_node = function(pos, oldnode, oldmetadata, user) local item = user:get_wielded_item() @@ -1735,24 +1735,24 @@ minetest.register_node("default:sponge", { on_water = true end for i=-1,1 do - p = {x=pos.x+i, y=pos.y, z=pos.z} - n = minetest.env:get_node(p) + local p = {x=pos.x+i, y=pos.y, z=pos.z} + local n = minetest.env:get_node(p) -- On verifie si il y a de l'eau if (n.name=="default:water_flowing") or (n.name == "default:water_source") then on_water = true end end for i=-1,1 do - p = {x=pos.x, y=pos.y+i, z=pos.z} - n = minetest.env:get_node(p) + local p = {x=pos.x, y=pos.y+i, z=pos.z} + local n = minetest.env:get_node(p) -- On verifie si il y a de l'eau if (n.name=="default:water_flowing") or (n.name == "default:water_source") then on_water = true end end for i=-1,1 do - p = {x=pos.x, y=pos.y, z=pos.z+i} - n = minetest.env:get_node(p) + local p = {x=pos.x, y=pos.y, z=pos.z+i} + local n = minetest.env:get_node(p) -- On verifie si il y a de l'eau if (n.name=="default:water_flowing") or (n.name == "default:water_source") then on_water = true @@ -1774,8 +1774,8 @@ minetest.register_node("default:sponge", { end end end - p = {x=pos.x, y=pos.y, z=pos.z} - n = minetest.env:get_node(p) + local p = {x=pos.x, y=pos.y, z=pos.z} + local n = minetest.env:get_node(p) if change == true then minetest.env:add_node(pointed_thing.above, {name = "default:sponge_wet"}) else