From f3aed139d68e12e2ceda2abd107386a23dbaf047 Mon Sep 17 00:00:00 2001 From: HybridDog Date: Fri, 22 May 2015 18:38:08 +0200 Subject: allow filling the watercan with e.g. river water. I didn't merge the part that would reject filling a watercan in areas you are protected from editing. It would make more sense if this was allowed, since the water block used to fill is not consumed. Also, I'd rather see code making sure that other people's plants can't be overwatered, which is more dangereous and I've not checked if that is possible now. --- init.lua | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/init.lua b/init.lua index 2e107bb..7382d2d 100644 --- a/init.lua +++ b/init.lua @@ -214,24 +214,21 @@ minetest.register_tool("crops:watering_can", { tool_capabilities = {}, on_use = function(itemstack, user, pointed_thing) local pos = pointed_thing.under - local ppos = pos - if pos == nil then + if not pos then return itemstack end -- filling it up? local node = minetest.get_node(pos) - if node.name == "default:water_source" or - node.name == "default:water_flowing" then + if minetest.get_item_group(node.name, "water") >= 3 then itemstack:set_wear(1) return itemstack end -- using it on a top-half part of a plant? local meta = minetest.get_meta(pos) if meta:get_int("crops_top_half") == 1 then - pos = {x = pos.x, y = pos.y - 1, z = pos.z} + meta = minetest.get_meta({x=pos.x, y=pos.y-1, z=pos.z}) end -- using it on a plant? - local meta = minetest.get_meta(pos) local water = meta:get_int("crops_water") if water == nil then return itemstack @@ -260,16 +257,15 @@ minetest.register_tool("crops:hydrometer", { }, on_use = function(itemstack, user, pointed_thing) local pos = pointed_thing.under - if pos == nil then + if not pos then return itemstack end -- doublesize plant? local meta = minetest.get_meta(pos) if meta:get_int("crops_top_half") == 1 then - pos = {x = pos.x, y = pos.y - 1, z = pos.z} + meta = minetest.get_meta({x=pos.x, y=pos.y-1, z=pos.z}) end - local meta = minetest.get_meta(pos) -- using it on a plant? local water = meta:get_int("crops_water") if water == nil then -- cgit v1.2.3