Fix stupid syntax bug
[minetest_wateringcan.git] / init.lua
blobb4dd388491efcc8194f5c5bdd4db73cee2b6f9d4
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,
6 stack_max = 1,
7 tool_capabilities = {
8 full_punch_interval = 2.0,
9 },
10 on_place = function(itemstack, user, pointed_thing)
11 if(pointed_thing.type == "node") then
12 local node = minetest.get_node_or_nil(pointed_thing.under)
13 if node ~= nil then
14 local name = node.name
15 local nodedef = minetest.registered_nodes[name]
16 local watered = true
17 local wear, newtool
18 if minetest.get_item_group(name, "water") > 0 then
19 newtool = { name = "wateringcan:wateringcan_water" }
20 watered = false
21 elseif name == "farming:soil" and minetest.get_modpath("farming") ~= nil then
22 minetest.set_node(pointed_thing.under, { name = "farming:soil_wet" })
23 elseif minetest.get_item_group(name, "sucky") > 0 and minetest.get_item_group(name, "wet") <= 2 and minetest.get_modpath("pedology") ~= nil then
24 pedology.wetten(pointed_thing.under)
25 end
27 if watered then
28 wear = itemstack:get_wear()
29 wear = wear + 2849 -- 24 uses
30 if(wear > 65535) then
31 newtool = { name = "wateringcan:wateringcan_empty" }
32 else
33 newtool = { name = "wateringcan:wateringcan_water", wear = wear }
34 end
35 end
36 return newtool
37 end
38 end
39 end
44 minetest.register_tool("wateringcan:wateringcan_empty", {
45 description = "empty watering can",
46 inventory_image = "wateringcan_wateringcan_empty.png",
47 wield_image = "wateringcan_wateringcan_wield.png",
48 liquids_pointable = true,
49 stack_max = 1,
50 tool_capabilities = {
51 full_punch_interval = 2.0,
53 on_place = function(itemstack, user, pointed_thing)
54 local node = minetest.get_node_or_nil(pointed_thing.under)
55 if node ~= nil then
56 local name = node.name
57 local nodedef = minetest.registered_nodes[name]
58 if minetest.get_item_group(name, "water") > 0 then
59 return { name = "wateringcan:wateringcan_water" }
60 end
61 end
62 end