From 472e69e774284d117467d9e5da0cb5965cee876b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 13 Jun 2014 21:08:14 +0200 Subject: [PATCH] When applying on plant, wetten node below it --- init.lua | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 06628da..cf4aa34 100644 --- a/init.lua +++ b/init.lua @@ -9,19 +9,34 @@ minetest.register_tool("wateringcan:wateringcan_water", { }, on_place = function(itemstack, user, pointed_thing) if(pointed_thing.type == "node") then - local node = minetest.get_node_or_nil(pointed_thing.under) + local pos = pointed_thing.under + local node = minetest.get_node_or_nil(pos) if node ~= nil then - local name = node.name - local nodedef = minetest.registered_nodes[name] + local name, nodedef local watered = true local wear, newtool + local underunder + if minetest.get_item_group(node.name, "plant") > 0 or minetest.get_item_group(node.name, "flora") > 0 then + pos = {x=pos.x, y=pos.y-1, z=pos.z} + underunder = minetest.get_node_or_nil(pos) + if(underunder ~= nil) then + name = underunder.name + nodedef = minetest.registered_nodes[name] + else + return itemstack + end + else + name = node.name + nodedef = minetest.registered_nodes[name] + end if minetest.get_item_group(name, "water") > 0 then newtool = { name = "wateringcan:wateringcan_water" } watered = false elseif name == "farming:soil" and minetest.get_modpath("farming") ~= nil then - minetest.set_node(pointed_thing.under, { name = "farming:soil_wet" }) + minetest.set_node(pos, { name = "farming:soil_wet" }) + elseif minetest.get_item_group(name, "sucky") > 0 and minetest.get_item_group(name, "wet") < 2 and minetest.get_modpath("pedology") ~= nil then - pedology.wetten(pointed_thing.under) + pedology.wetten(pos) end if watered then -- 2.11.4.GIT