2
0

init.lua 788 B

123456789101112131415161718192021222324252627
  1. -- Bucket: Punch liquid source or flowing liquid to collect it
  2. core.register_tool("bucket:bucket", {
  3. description = "Bucket".."\n"..
  4. "Picks up liquid nodes",
  5. inventory_image = "bucket.png",
  6. stack_max = 1,
  7. liquids_pointable = true,
  8. groups = { disable_repair = 1 },
  9. on_use = function(itemstack, user, pointed_thing)
  10. -- Must be pointing to node
  11. if pointed_thing.type ~= "node" then
  12. return
  13. end
  14. -- Check if pointing to a liquid
  15. local n = core.get_node(pointed_thing.under)
  16. local def = core.registered_nodes[n.name]
  17. if def ~= nil and (def.liquidtype == "source" or def.liquidtype == "flowing") then
  18. core.add_node(pointed_thing.under, {name="air"})
  19. local inv = user:get_inventory()
  20. if inv then
  21. inv:add_item("main", ItemStack(n.name))
  22. end
  23. end
  24. end,
  25. })