fixes
This commit is contained in:
parent
03ff573adb
commit
12867e4e5e
@ -5,13 +5,13 @@ This API adds support for `fluid_buffers` inside nodes. This means that nodes ca
|
||||
1. Add the node to the `fluid_container` group.
|
||||
2. Add the following to the node defintion:
|
||||
```
|
||||
fluid_buffers = {
|
||||
fluid_buffers = {
|
||||
buffer_name = {
|
||||
capacity = 2000,
|
||||
accepts = {"default:water_source", "group:water_source"}, -- you can also set this to true to accept any fluid!
|
||||
drainable = true,
|
||||
},
|
||||
}
|
||||
}
|
||||
```
|
||||
3. Set the appropriate metadata.
|
||||
|
||||
@ -27,13 +27,13 @@ All numbers are in **milli-buckets** (1 bucket = 1000 mB).
|
||||
* `fluid_lib.get_buffer_data(pos, buffer)`
|
||||
* Returns all the information about this buffer.
|
||||
```
|
||||
{
|
||||
{
|
||||
fluid = fluid source block,
|
||||
amount = amount of fluid,
|
||||
accepts = list of accepted fluids,
|
||||
capacity = capacity of the buffer,
|
||||
drainable = is this buffer drainable,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* `fluid_lib.buffer_accepts_fluid(pos, buffer, fluid)`
|
||||
|
@ -111,15 +111,18 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
|
||||
-- Fill any fluid buffers if present
|
||||
local place = true
|
||||
if ndef.fluid_buffers then
|
||||
local buffers = fluid_lib.get_node_buffers(lpos)
|
||||
local ppos = pointed_thing.under
|
||||
local buffers = fluid_lib.get_node_buffers(ppos)
|
||||
if buffers then
|
||||
for buffer in pairs(buffers) do
|
||||
if fluid_lib.can_insert_into_buffer(lpos, buffer, source, 1000) == 1000 then
|
||||
fluid_lib.insert_into_buffer(lpos, buffer, source, 1000)
|
||||
if fluid_lib.can_insert_into_buffer(ppos, buffer, source, 1000) == 1000 then
|
||||
fluid_lib.insert_into_buffer(ppos, buffer, source, 1000)
|
||||
place = false
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if place then
|
||||
minetest.set_node(lpos, {name = source})
|
||||
@ -222,7 +225,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
||||
|
||||
if check_protection(lpos, user
|
||||
and user:get_player_name()
|
||||
or "", "take "..source) then
|
||||
or "", "take "..node.name) then
|
||||
return
|
||||
end
|
||||
|
||||
@ -231,6 +234,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
||||
-- Remove fluid from buffers if present
|
||||
if ndef.fluid_buffers then
|
||||
local buffers = fluid_lib.get_node_buffers(lpos)
|
||||
if buffers then
|
||||
for buffer in pairs(buffers) do
|
||||
if fluid_lib.can_take_from_buffer(lpos, buffer, 1000) == 1000 then
|
||||
local fluid = fluid_lib.take_from_buffer(lpos, buffer, 1000)
|
||||
@ -241,6 +245,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
|
@ -69,7 +69,7 @@ end
|
||||
function fluid_lib.can_insert_into_buffer(pos, buffer, fluid, count)
|
||||
local bfdata = fluid_lib.get_buffer_data(pos, buffer)
|
||||
if not bfdata then return 0 end
|
||||
if bfdata.fluid ~= fluid and bfdata.fluid ~= "" then return 0 end
|
||||
if not fluid_lib.buffer_accepts_fluid(pos, buffer, fluid) then return 0 end
|
||||
|
||||
local can_put = 0
|
||||
if bfdata.amount + count > bfdata.capacity then
|
||||
|
Loading…
Reference in New Issue
Block a user