From 35353c1d0801c61c54fc04a8c89a3ec3b8475b35 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 14 Feb 2017 03:42:11 +0100 Subject: [PATCH] Add support for empty bucket in dispenser --- mods/redstone/mcl_dispensers/init.lua | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mods/redstone/mcl_dispensers/init.lua b/mods/redstone/mcl_dispensers/init.lua index 81206f384..c91e528cf 100644 --- a/mods/redstone/mcl_dispensers/init.lua +++ b/mods/redstone/mcl_dispensers/init.lua @@ -100,6 +100,38 @@ local dispenserdef = { minetest.set_node(droppos, {name = iname}) tnt.ignite(droppos) + stack:take_item() + inv:set_stack("main", stack_id, stack) + end + elseif iname == "bucket:bucket_empty" then + -- Fill empty bucket with liquid or drop bucket if no liquid + local collect_liquid = false + local bucket_id + if dropnode.name == "mcl_core:water_source" then + collect_liquid = true + bucket_id = "bucket:bucket_water" + elseif dropnode.name == "mcl_core:lava_source" then + collect_liquid = true + bucket_id = "bucket:bucket_lava" + end + if collect_liquid then + minetest.swap_node(droppos, {name="air"}) + + -- Fill bucket with liquid and put it back into inventory + -- if there's still space. If not, drop it. + stack:take_item() + inv:set_stack("main", stack_id, stack) + + local new_bucket = ItemStack(bucket_id) + if inv:room_for_item("main", new_bucket) then + inv:add_item("main", new_bucket) + else + minetest.add_item(droppos, dropitem) + end + else + -- No liquid found: Drop empty bucket + minetest.add_item(droppos, dropitem) + stack:take_item() inv:set_stack("main", stack_id, stack) end