2020-05-24 15:46:26 +02:00
|
|
|
-- Bucket: Punch liquid source or flowing liquid to collect it
|
2011-12-03 23:51:19 +01:00
|
|
|
|
2024-10-28 15:57:54 +01:00
|
|
|
core.register_tool("bucket:bucket", {
|
2020-09-04 20:50:03 +02:00
|
|
|
description = "Bucket".."\n"..
|
|
|
|
"Picks up liquid nodes",
|
2012-01-12 06:10:39 +01:00
|
|
|
inventory_image = "bucket.png",
|
2011-11-29 16:44:07 +01:00
|
|
|
stack_max = 1,
|
|
|
|
liquids_pointable = true,
|
2020-05-24 15:46:26 +02:00
|
|
|
groups = { disable_repair = 1 },
|
2012-01-12 06:10:39 +01:00
|
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
|
|
-- Must be pointing to node
|
|
|
|
if pointed_thing.type ~= "node" then
|
|
|
|
return
|
|
|
|
end
|
2020-05-24 15:46:26 +02:00
|
|
|
-- Check if pointing to a liquid
|
2024-10-28 15:57:54 +01:00
|
|
|
local n = core.get_node(pointed_thing.under)
|
|
|
|
local def = core.registered_nodes[n.name]
|
2020-05-24 15:46:26 +02:00
|
|
|
if def ~= nil and (def.liquidtype == "source" or def.liquidtype == "flowing") then
|
2024-10-28 15:57:54 +01:00
|
|
|
core.add_node(pointed_thing.under, {name="air"})
|
2020-05-24 15:46:26 +02:00
|
|
|
local inv = user:get_inventory()
|
|
|
|
if inv then
|
|
|
|
inv:add_item("main", ItemStack(n.name))
|
|
|
|
end
|
2011-11-29 16:44:07 +01:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|