]> git.lizzy.rs Git - dragonfireclient.git/blob - games/devtest/mods/bucket/init.lua
Devtest: Extend tooltips of many items and tools (#10312)
[dragonfireclient.git] / games / devtest / mods / bucket / init.lua
1 -- Bucket: Punch liquid source or flowing liquid to collect it
2
3 minetest.register_tool("bucket:bucket", {
4         description = "Bucket".."\n"..
5                 "Picks up liquid nodes",
6         inventory_image = "bucket.png",
7         stack_max = 1,
8         liquids_pointable = true,
9         groups = { disable_repair = 1 },
10         on_use = function(itemstack, user, pointed_thing)
11                 -- Must be pointing to node
12                 if pointed_thing.type ~= "node" then
13                         return
14                 end
15                 -- Check if pointing to a liquid
16                 local n = minetest.get_node(pointed_thing.under)
17                 local def = minetest.registered_nodes[n.name]
18                 if def ~= nil and (def.liquidtype == "source" or def.liquidtype == "flowing") then
19                         minetest.add_node(pointed_thing.under, {name="air"})
20                         local inv = user:get_inventory()
21                         if inv then
22                                 inv:add_item("main", ItemStack(n.name))
23                         end
24                 end
25         end,
26 })
27