1 minetest
.register_tool("wateringcan:wateringcan_water", {
2 description
= "watering can with water",
3 inventory_image
= "wateringcan_wateringcan_water.png",
4 wield_image
= "wateringcan_wateringcan_wield.png",
5 liquids_pointable
= true,
8 full_punch_interval
= 2.0,
10 on_place
= function(itemstack
, user
, pointed_thing
)
11 if(pointed_thing
.type == "node") then
12 local pos
= pointed_thing
.under
13 local node
= minetest
.get_node_or_nil(pos
)
19 if minetest
.get_item_group(node
.name
, "plant") > 0 or minetest
.get_item_group(node
.name
, "flora") > 0 then
20 pos
= {x
=pos
.x
, y
=pos
.y
-1, z
=pos
.z
}
21 underunder
= minetest
.get_node_or_nil(pos
)
22 if(underunder
~= nil) then
23 name
= underunder
.name
24 nodedef
= minetest
.registered_nodes
[name
]
30 nodedef
= minetest
.registered_nodes
[name
]
32 if minetest
.get_item_group(name
, "water") > 0 then
33 newtool
= { name
= "wateringcan:wateringcan_water" }
35 elseif name
== "farming:soil" and minetest
.get_modpath("farming") ~= nil then
36 minetest
.set_node(pos
, { name
= "farming:soil_wet" })
38 elseif minetest
.get_item_group(name
, "sucky") > 0 and minetest
.get_item_group(name
, "wet") < 2 and minetest
.get_modpath("pedology") ~= nil then
43 wear
= itemstack
:get_wear()
44 wear
= wear
+ 2849 -- 24 uses
46 newtool
= { name
= "wateringcan:wateringcan_empty" }
48 newtool
= { name
= "wateringcan:wateringcan_water", wear
= wear
}
59 minetest
.register_tool("wateringcan:wateringcan_empty", {
60 description
= "empty watering can",
61 inventory_image
= "wateringcan_wateringcan_empty.png",
62 wield_image
= "wateringcan_wateringcan_wield.png",
63 liquids_pointable
= true,
66 full_punch_interval
= 2.0,
68 on_place
= function(itemstack
, user
, pointed_thing
)
69 local node
= minetest
.get_node_or_nil(pointed_thing
.under
)
71 local name
= node
.name
72 local nodedef
= minetest
.registered_nodes
[name
]
73 if minetest
.get_item_group(name
, "water") > 0 then
74 return { name
= "wateringcan:wateringcan_water" }