forked from VoxeLibre/VoxeLibre
Add support for empty bucket in dispenser
This commit is contained in:
parent
eaeebd900b
commit
35353c1d08
|
@ -100,6 +100,38 @@ local dispenserdef = {
|
||||||
minetest.set_node(droppos, {name = iname})
|
minetest.set_node(droppos, {name = iname})
|
||||||
tnt.ignite(droppos)
|
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()
|
stack:take_item()
|
||||||
inv:set_stack("main", stack_id, stack)
|
inv:set_stack("main", stack_id, stack)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue