2 if (minetest
.get_modpath("intllib")) then
3 dofile(minetest
.get_modpath("intllib").."/intllib.lua")
4 S
= intllib
.Getter(minetest
.get_current_modname())
6 S
= function ( s
) return s
end
9 minetest
.register_tool("wateringcan:wateringcan_water", {
10 description
= S("Watering can with water"),
11 x_doc_items_create_entry
= false,
12 inventory_image
= "wateringcan_wateringcan_water.png",
13 wield_image
= "wateringcan_wateringcan_wield.png",
14 liquids_pointable
= true,
17 full_punch_interval
= 2.0,
19 on_place
= function(itemstack
, user
, pointed_thing
)
20 if(pointed_thing
.type == "node") then
21 local pos
= pointed_thing
.under
22 local node
= minetest
.get_node_or_nil(pos
)
28 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
29 pos
= {x
=pos
.x
, y
=pos
.y
-1, z
=pos
.z
}
30 underunder
= minetest
.get_node_or_nil(pos
)
31 if(underunder
~= nil) then
32 name
= underunder
.name
33 nodedef
= minetest
.registered_nodes
[name
]
39 nodedef
= minetest
.registered_nodes
[name
]
41 if minetest
.get_item_group(name
, "water") > 0 then
42 newtool
= { name
= "wateringcan:wateringcan_water" }
44 elseif name
== "farming:soil" and minetest
.get_modpath("farming") ~= nil then
45 minetest
.set_node(pos
, { name
= "farming:soil_wet" })
46 elseif name
== "farming:desert_sand_soil" and minetest
.get_modpath("farming") ~= nil then
47 minetest
.set_node(pos
, { name
= "farming:desert_sand_soil_wet" })
49 elseif minetest
.get_item_group(name
, "sucky") > 0 and minetest
.get_item_group(name
, "wet") < 2 and minetest
.get_modpath("pedology") ~= nil then
54 minetest
.sound_play({name
= "wateringcan_pour", gain
= 0.25, max_hear_distance
= 10}, { pos
= user
:getpos() })
55 wear
= itemstack
:get_wear()
56 wear
= wear
+ 2849 -- 24 uses
58 newtool
= { name
= "wateringcan:wateringcan_empty" }
60 newtool
= { name
= "wateringcan:wateringcan_water", wear
= wear
}
70 minetest
.register_tool("wateringcan:wateringcan_empty", {
71 description
= S("Empty watering can"),
72 x_doc_items_entry_name
= S("Watering can"),
73 x_doc_items_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 x_doc_items_usagehelp
= S("Rightclick on water (or any other block belonging to the “Water” 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."),
75 inventory_image
= "wateringcan_wateringcan_empty.png",
76 wield_image
= "wateringcan_wateringcan_wield.png",
77 liquids_pointable
= true,
80 full_punch_interval
= 2.0,
82 on_place
= function(itemstack
, user
, pointed_thing
)
83 local node
= minetest
.get_node_or_nil(pointed_thing
.under
)
85 local name
= node
.name
86 local nodedef
= minetest
.registered_nodes
[name
]
87 if minetest
.get_item_group(name
, "water") > 0 then
88 return { name
= "wateringcan:wateringcan_water" }
94 if minetest
.get_modpath("bucket") ~= nil then
95 if minetest
.get_modpath("default") ~= nil then
96 minetest
.register_craft({
97 output
= "wateringcan:wateringcan_empty",
99 {"", "", "default:steel_ingot"},
100 {"group:stick", "default:steel_ingot", ""},
101 {"default:steel_ingot", "bucket:bucket_empty", ""},
104 minetest
.register_craft({
105 output
= "wateringcan:wateringcan_water",
107 {"", "", "default:steel_ingot"},
108 {"group:stick", "default:steel_ingot", ""},
109 {"default:steel_ingot", "group:water_bucket", ""},
113 minetest
.register_craft({
114 output
= "wateringcan:wateringcan_water",
116 recipe
= {"wateringcan:wateringcan_empty", "group:water_bucket"},
117 replacements
= {{"group:water_bucket", "bucket:bucket_empty"}}
121 if minetest
.get_modpath("doc") ~= nil then
122 doc
.add_entry_alias("tools", "wateringcan:wateringcan_empty", "wateringcan:wateringcan_water")