2014-06-13 16:35:40 +02:00
|
|
|
minetest.register_tool("wateringcan:wateringcan_water", {
|
|
|
|
description = "watering can with water",
|
|
|
|
inventory_image = "wateringcan_wateringcan_water.png",
|
|
|
|
wield_image = "wateringcan_wateringcan_wield.png",
|
2014-06-13 16:59:54 +02:00
|
|
|
liquids_pointable = true,
|
|
|
|
stack_max = 1,
|
|
|
|
tool_capabilities = {
|
|
|
|
full_punch_interval = 2.0,
|
|
|
|
},
|
2014-06-13 16:35:40 +02:00
|
|
|
on_place = function(itemstack, user, pointed_thing)
|
|
|
|
if(pointed_thing.type == "node") then
|
|
|
|
local node = minetest.get_node_or_nil(pointed_thing.under)
|
|
|
|
if node ~= nil then
|
|
|
|
local name = node.name
|
|
|
|
local nodedef = minetest.registered_nodes[name]
|
2014-06-13 17:57:37 +02:00
|
|
|
local watered = true
|
2014-06-13 16:59:54 +02:00
|
|
|
local wear, newtool
|
2014-06-13 17:21:28 +02:00
|
|
|
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
|
2014-06-13 16:35:40 +02:00
|
|
|
minetest.set_node(pointed_thing.under, { name = "farming:soil_wet" })
|
2014-06-13 17:57:37 +02:00
|
|
|
elseif minetest.get_item_group(name, "sucky") > 0 and minetest.get_item_group(name, "wet" <= 2) and minetest.get_modpath("pedology") ~= nil then
|
2014-06-13 16:35:40 +02:00
|
|
|
pedology.wetten(pointed_thing.under)
|
|
|
|
end
|
2014-06-13 17:21:28 +02:00
|
|
|
|
2014-06-13 16:59:54 +02:00
|
|
|
if watered then
|
|
|
|
wear = itemstack:get_wear()
|
|
|
|
wear = wear + 2849 -- 24 uses
|
|
|
|
if(wear > 65535) then
|
|
|
|
newtool = { name = "wateringcan:wateringcan_empty" }
|
|
|
|
else
|
|
|
|
newtool = { name = "wateringcan:wateringcan_water", wear = wear }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return newtool
|
2014-06-13 16:35:40 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2014-06-13 16:59:54 +02:00
|
|
|
minetest.register_tool("wateringcan:wateringcan_empty", {
|
2014-06-13 16:35:40 +02:00
|
|
|
description = "empty watering can",
|
|
|
|
inventory_image = "wateringcan_wateringcan_empty.png",
|
|
|
|
wield_image = "wateringcan_wateringcan_wield.png",
|
2014-06-13 16:59:54 +02:00
|
|
|
liquids_pointable = true,
|
|
|
|
stack_max = 1,
|
|
|
|
tool_capabilities = {
|
|
|
|
full_punch_interval = 2.0,
|
|
|
|
},
|
2014-06-13 17:21:28 +02:00
|
|
|
on_place = function(itemstack, user, pointed_thing)
|
|
|
|
local node = minetest.get_node_or_nil(pointed_thing.under)
|
|
|
|
if node ~= nil then
|
|
|
|
local name = node.name
|
|
|
|
local nodedef = minetest.registered_nodes[name]
|
|
|
|
if minetest.get_item_group(name, "water") > 0 then
|
|
|
|
return { name = "wateringcan:wateringcan_water" }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-06-13 16:59:54 +02:00
|
|
|
})
|