mirror of
https://gitlab.icynet.eu/evert/fluid_lib.git
synced 2024-12-18 11:15:43 +01:00
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.
|
1. Add the node to the `fluid_container` group.
|
||||||
2. Add the following to the node defintion:
|
2. Add the following to the node defintion:
|
||||||
```
|
```
|
||||||
fluid_buffers = {
|
fluid_buffers = {
|
||||||
buffer_name = {
|
buffer_name = {
|
||||||
capacity = 2000,
|
capacity = 2000,
|
||||||
accepts = {"default:water_source", "group:water_source"}, -- you can also set this to true to accept any fluid!
|
accepts = {"default:water_source", "group:water_source"}, -- you can also set this to true to accept any fluid!
|
||||||
drainable = true,
|
drainable = true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
3. Set the appropriate metadata.
|
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)`
|
* `fluid_lib.get_buffer_data(pos, buffer)`
|
||||||
* Returns all the information about this buffer.
|
* Returns all the information about this buffer.
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
fluid = fluid source block,
|
fluid = fluid source block,
|
||||||
amount = amount of fluid,
|
amount = amount of fluid,
|
||||||
accepts = list of accepted fluids,
|
accepts = list of accepted fluids,
|
||||||
capacity = capacity of the buffer,
|
capacity = capacity of the buffer,
|
||||||
drainable = is this buffer drainable,
|
drainable = is this buffer drainable,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* `fluid_lib.buffer_accepts_fluid(pos, buffer, fluid)`
|
* `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
|
-- Fill any fluid buffers if present
|
||||||
local place = true
|
local place = true
|
||||||
if ndef.fluid_buffers then
|
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
|
for buffer in pairs(buffers) do
|
||||||
if fluid_lib.can_insert_into_buffer(lpos, buffer, source, 1000) == 1000 then
|
if fluid_lib.can_insert_into_buffer(ppos, buffer, source, 1000) == 1000 then
|
||||||
fluid_lib.insert_into_buffer(lpos, buffer, source, 1000)
|
fluid_lib.insert_into_buffer(ppos, buffer, source, 1000)
|
||||||
place = false
|
place = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if place then
|
if place then
|
||||||
minetest.set_node(lpos, {name = source})
|
minetest.set_node(lpos, {name = source})
|
||||||
@ -222,7 +225,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
|||||||
|
|
||||||
if check_protection(lpos, user
|
if check_protection(lpos, user
|
||||||
and user:get_player_name()
|
and user:get_player_name()
|
||||||
or "", "take "..source) then
|
or "", "take "..node.name) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -231,6 +234,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
|||||||
-- Remove fluid from buffers if present
|
-- Remove fluid from buffers if present
|
||||||
if ndef.fluid_buffers then
|
if ndef.fluid_buffers then
|
||||||
local buffers = fluid_lib.get_node_buffers(lpos)
|
local buffers = fluid_lib.get_node_buffers(lpos)
|
||||||
|
if buffers then
|
||||||
for buffer in pairs(buffers) do
|
for buffer in pairs(buffers) do
|
||||||
if fluid_lib.can_take_from_buffer(lpos, buffer, 1000) == 1000 then
|
if fluid_lib.can_take_from_buffer(lpos, buffer, 1000) == 1000 then
|
||||||
local fluid = fluid_lib.take_from_buffer(lpos, buffer, 1000)
|
local fluid = fluid_lib.take_from_buffer(lpos, buffer, 1000)
|
||||||
@ -241,6 +245,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
@ -69,7 +69,7 @@ end
|
|||||||
function fluid_lib.can_insert_into_buffer(pos, buffer, fluid, count)
|
function fluid_lib.can_insert_into_buffer(pos, buffer, fluid, count)
|
||||||
local bfdata = fluid_lib.get_buffer_data(pos, buffer)
|
local bfdata = fluid_lib.get_buffer_data(pos, buffer)
|
||||||
if not bfdata then return 0 end
|
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
|
local can_put = 0
|
||||||
if bfdata.amount + count > bfdata.capacity then
|
if bfdata.amount + count > bfdata.capacity then
|
||||||
|
Loading…
Reference in New Issue
Block a user