1
0
Fork 0

Add support for empty bucket in dispenser

objects
Wuzzy 2017-02-14 03:42:11 +01:00
parent eaeebd900b
commit 35353c1d08
1 changed files with 32 additions and 0 deletions

View File

@ -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