When applying on plant, wetten node below it

This commit is contained in:
Wuzzy 2014-06-13 21:08:14 +02:00
parent e0e6f0889d
commit 472e69e774

@ -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