1 local S
= minetest
.get_translator("wateringcan")
3 minetest
.register_tool("wateringcan:wateringcan_water", {
4 description
= S("Watering can with water"),
5 _doc_items_create_entry
= false,
6 inventory_image
= "wateringcan_wateringcan_water.png",
7 wield_image
= "wateringcan_wateringcan_wield.png",
8 liquids_pointable
= true,
10 groups
= { disable_repair
= 1 },
12 full_punch_interval
= 2.0,
14 on_place
= function(itemstack
, user
, pointed_thing
)
15 if(pointed_thing
.type == "node") then
16 local pos
= pointed_thing
.under
17 local node
= minetest
.get_node_or_nil(pos
)
23 if minetest
.get_item_group(node
.name
, "plant") > 0 or minetest
.get_item_group(node
.name
, "flora") > 0 or minetest
.get_item_group(node
.name
, "seed") > 0 then
24 pos
= {x
=pos
.x
, y
=pos
.y
-1, z
=pos
.z
}
25 underunder
= minetest
.get_node_or_nil(pos
)
26 if(underunder
~= nil) then
27 name
= underunder
.name
28 nodedef
= minetest
.registered_nodes
[name
]
34 nodedef
= minetest
.registered_nodes
[name
]
36 if minetest
.get_item_group(name
, "water") > 0 then
37 newtool
= { name
= "wateringcan:wateringcan_water" }
39 minetest
.sound_play({name
= "wateringcan_fill", gain
= 0.25, max_hear_distance
= 10}, { pos
= user
:get_pos() }, true)
40 elseif name
== "farming:soil" and minetest
.get_modpath("farming") ~= nil then
41 minetest
.set_node(pos
, { name
= "farming:soil_wet" })
42 elseif name
== "farming:desert_sand_soil" and minetest
.get_modpath("farming") ~= nil then
43 minetest
.set_node(pos
, { name
= "farming:desert_sand_soil_wet" })
45 elseif minetest
.get_item_group(name
, "sucky") > 0 and minetest
.get_item_group(name
, "wet") < 2 and minetest
.get_modpath("pedology") ~= nil then
50 minetest
.sound_play({name
= "wateringcan_pour", gain
= 0.25, max_hear_distance
= 10}, { pos
= user
:get_pos() }, true)
51 wear
= itemstack
:get_wear()
52 wear
= wear
+ 2849 -- 24 uses
54 newtool
= { name
= "wateringcan:wateringcan_empty" }
56 newtool
= { name
= "wateringcan:wateringcan_water", wear
= wear
}
66 local usagehelp
, longdesc
, entry_name
68 if minetest
.get_modpath("doc_items") then
69 usagehelp
= S("Rightclick on water (or any other block belonging to the “@1” group) to fill or refill the watering can. Rightclick with the filled can on an appropriate block (or a plant above it) to wetten it. Soil, desert sand soil, and other blocks capable of becoming wet can be wettened. The tool wear indicator of the watering can indicates the amount of water left.", doc
.sub
.items
.get_group_name("water"))
70 entry_name
= S("Watering can")
71 longdesc
= S("Watering cans are used to collect a small amount of water in order to pour it on dry blocks. One filled watering can can be used 24 times, after which it has to be refilled. Watering cans don't wear out.")
74 minetest
.register_tool("wateringcan:wateringcan_empty", {
75 description
= S("Empty watering can"),
76 _doc_items_entry_name
= entry_name
,
77 _doc_items_longdesc
= longdesc
,
78 _doc_items_usagehelp
= usagehelp
,
79 inventory_image
= "wateringcan_wateringcan_empty.png",
80 wield_image
= "wateringcan_wateringcan_wield.png",
81 liquids_pointable
= true,
83 groups
= { disable_repair
= 1 },
85 full_punch_interval
= 2.0,
87 on_place
= function(itemstack
, user
, pointed_thing
)
88 local node
= minetest
.get_node_or_nil(pointed_thing
.under
)
90 local name
= node
.name
91 local nodedef
= minetest
.registered_nodes
[name
]
92 if minetest
.get_item_group(name
, "water") > 0 then
93 minetest
.sound_play({name
= "wateringcan_fill", gain
= 0.25, max_hear_distance
= 10}, { pos
= user
:get_pos() }, true)
94 return { name
= "wateringcan:wateringcan_water" }
100 if minetest
.get_modpath("bucket") ~= nil then
101 if minetest
.get_modpath("default") ~= nil then
102 minetest
.register_craft({
103 output
= "wateringcan:wateringcan_empty",
105 {"", "", "default:steel_ingot"},
106 {"group:stick", "default:steel_ingot", ""},
107 {"default:steel_ingot", "bucket:bucket_empty", ""},
110 minetest
.register_craft({
111 output
= "wateringcan:wateringcan_water",
113 {"", "", "default:steel_ingot"},
114 {"group:stick", "default:steel_ingot", ""},
115 {"default:steel_ingot", "group:water_bucket", ""},
119 minetest
.register_craft({
120 output
= "wateringcan:wateringcan_water",
122 recipe
= {"wateringcan:wateringcan_empty", "group:water_bucket"},
123 replacements
= {{"group:water_bucket", "bucket:bucket_empty"}}
127 if minetest
.get_modpath("doc") ~= nil and minetest
.get_modpath("doc_items") ~= nil then
128 doc
.add_entry_alias("tools", "wateringcan:wateringcan_empty", "tools", "wateringcan:wateringcan_water")