mirror of
https://gitlab.icynet.eu/evert/fluid_lib.git
synced 2024-12-18 11:15:43 +01:00
Bucket now uses Node IO endpoints
This commit is contained in:
parent
a587717bd8
commit
4237ff7206
@ -110,20 +110,15 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
|
|||||||
|
|
||||||
-- Fill any fluid buffers if present
|
-- Fill any fluid buffers if present
|
||||||
local place = true
|
local place = true
|
||||||
if ndef.fluid_buffers then
|
local ppos = pointed_thing.under
|
||||||
local ppos = pointed_thing.under
|
local node = minetest.get_node(ppos)
|
||||||
local buffers = fluid_lib.get_node_buffers(ppos)
|
if ndef.node_io_can_put_liquid and ndef.node_io_can_put_liquid(ppos, node, "") then
|
||||||
if buffers then
|
if ndef.node_io_room_for_liquid(ppos, node, "", source, 1000) >= 1000 then
|
||||||
for buffer in pairs(buffers) do
|
ndef.node_io_put_liquid(ppos, node, "", nil, source, 1000)
|
||||||
if fluid_lib.can_insert_into_buffer(ppos, buffer, source, 1000) == 1000 then
|
if ndef.on_timer then
|
||||||
fluid_lib.insert_into_buffer(ppos, buffer, source, 1000)
|
minetest.get_node_timer(ppos):start(ndef.node_timer_seconds or 1.0)
|
||||||
if ndef.on_timer then
|
|
||||||
minetest.get_node_timer(ppos):start(ndef.node_timer_seconds or 1.0)
|
|
||||||
end
|
|
||||||
place = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
place = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -248,19 +243,26 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
|||||||
itemstack = ItemStack("bucket:bucket_empty")
|
itemstack = ItemStack("bucket:bucket_empty")
|
||||||
|
|
||||||
-- Remove fluid from buffers if present
|
-- Remove fluid from buffers if present
|
||||||
if ndef.fluid_buffers then
|
if ndef.node_io_can_take_liquid and ndef.node_io_can_take_liquid(lpos, node, "") then
|
||||||
local buffers = fluid_lib.get_node_buffers(lpos)
|
local bfc = ndef.node_io_get_liquid_size(lpos, node, "")
|
||||||
if buffers then
|
local buffers = {}
|
||||||
for buffer in pairs(buffers) do
|
for i = 1, bfc do
|
||||||
if fluid_lib.can_take_from_buffer(lpos, buffer, 1000) == 1000 then
|
buffers[i] = ndef.node_io_get_liquid_name(lpos, node, "", i)
|
||||||
local fluid = fluid_lib.take_from_buffer(lpos, buffer, 1000)
|
end
|
||||||
if bucket.liquids[fluid] then
|
|
||||||
itemstack = ItemStack(bucket.liquids[fluid].itemname)
|
if #buffers > 0 then
|
||||||
if ndef.on_timer then
|
for id,fluid in pairs(buffers) do
|
||||||
minetest.get_node_timer(lpos):start(ndef.node_timer_seconds or 1.0)
|
if fluid ~= "" then
|
||||||
|
local took = ndef.node_io_take_liquid(lpos, node, "", nil, fluid, 1000)
|
||||||
|
if took.millibuckets == 1000 and took.name == fluid then
|
||||||
|
if bucket.liquids[fluid] then
|
||||||
|
itemstack = ItemStack(bucket.liquids[fluid].itemname)
|
||||||
|
if ndef.on_timer then
|
||||||
|
minetest.get_node_timer(lpos):start(ndef.node_timer_seconds or 1.0)
|
||||||
|
end
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user