From 21f625358716a7b4df7224b6292e8c7bd2143790 Mon Sep 17 00:00:00 2001 From: davedevils Date: Wed, 1 Jul 2015 07:56:51 +0200 Subject: [PATCH] Finish and clean the group dig_by_water , and now the fire can be stopped by water --- mods/default/functions.lua | 31 +++++++++++++++++++++++-------- mods/farming/init.lua | 21 --------------------- mods/fire/init.lua | 2 +- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 46f2c36262..62c2f00036 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -96,22 +96,37 @@ 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"}) + action = function(pos, node, active_object_count, active_object_count_wider) + for xp=-1,1 do + for zp=-1,1 do + local p = {x=pos.x+xp, y=pos.y, z=pos.z+zp} + local n = minetest.env:get_node(p) + -- On verifie si il y a de l'eau + if (n.name=="default:water_flowing") then + drop_attached_node(pos) + minetest.env:dig_node(pos) + break end end end + -- cas rare + for yp=-1,1 do + local p = {x=pos.x, y=pos.y+yp, 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") then + drop_attached_node(pos) + minetest.env:dig_node(pos) + break + end + end + end, }) diff --git a/mods/farming/init.lua b/mods/farming/init.lua index 2197c57c10..6b9ecbf65b 100644 --- a/mods/farming/init.lua +++ b/mods/farming/init.lua @@ -65,27 +65,6 @@ function farming:place_seed(itemstack, placer, pointed_thing, plantname) end -minetest.register_abm({ - nodenames = {"group:dig_by_water"}, - neighbors = {"group:water"}, - interval = 1, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - for xp=-1,1 do - for zp=-1,1 do - p = {x=pos.x+xp, y=pos.y, z=pos.z+zp} - n = minetest.env:get_node(p) - -- On verifie si il y a de l'eau - if (n.name=="default:water_flowing") then - drop_attached_node(pos) - minetest.env:dig_node(pos) - break - end - end - end - - end, -}) -- ========= SOIL ========= dofile(minetest.get_modpath("farming").."/soil.lua") diff --git a/mods/fire/init.lua b/mods/fire/init.lua index d82f350f41..b9dedbe012 100644 --- a/mods/fire/init.lua +++ b/mods/fire/init.lua @@ -9,7 +9,7 @@ minetest.register_node("fire:basic_flame", { }}, inventory_image = "fire_basic_flame.png", light_source = 14, - groups = {igniter=2,dig_immediate=3,hot=3}, + groups = {igniter=2,dig_immediate=3,hot=3,dig_by_water=1}, drop = '', walkable = false, buildable_to = true,