fix pump issue (silo source items can disappear)

This commit is contained in:
Joachim Stolberg 2020-09-11 14:33:09 +02:00
parent be8e9b3b8c
commit 3ca31bd0ba
4 changed files with 33 additions and 1 deletions

View File

@ -162,6 +162,17 @@ function liquid.take(pos, outdir, name, amount, player_name)
return taken, item_name
end
function liquid.untake(pos, outdir, name, amount, player_name)
for _,item in ipairs(get_network_table(pos, outdir, "tank")) do
local liquid = LQD(item.pos)
if liquid and liquid.untake then
amount = liquid.untake(item.pos, item.indir, name, amount)
if not amount or amount == 0 then break end
end
end
return amount or 0
end
--
-- Server local functions
--

View File

@ -70,7 +70,7 @@ local function pumping(pos, nvm, state, capa)
if taken > 0 then
local leftover = liquid.put(pos, outdir, name, taken, starter)
if leftover and leftover == taken then
liquid.put(pos, Flip[outdir], name, leftover)
liquid.untake(pos, Flip[outdir], name, leftover)
state:blocked(pos, nvm)
return
end

View File

@ -126,6 +126,15 @@ local tLiquid = {
end
return 0
end,
untake = function(pos, indir, name, amount)
local inv = M(pos):get_inventory()
local stack = ItemStack(name.." "..amount)
if inv:room_for_item("main", stack) then
inv:add_item("main", stack)
return 0
end
return amount
end,
}
local tNetworks = {

View File

@ -67,6 +67,15 @@ local function put_liquid(pos, indir, name, amount)
return amount
end
local function untake_liquid(pos, indir, name, amount)
local leftover = liquid.srv_put(pos, indir, name, amount)
if techage.is_activeformspec(pos) then
local nvm = techage.get_nvm(pos)
M(pos):set_string("formspec", liquid.formspec(pos, nvm))
end
return leftover
end
local networks_def = {
pipe2 = {
sides = techage.networks.AllSides, -- Pipe connection sides
@ -110,6 +119,7 @@ minetest.register_node("techage:ta3_tank", {
peek = liquid.srv_peek,
put = put_liquid,
take = take_liquid,
untake = untake_liquid,
},
networks = networks_def,
on_rightclick = on_rightclick,
@ -168,6 +178,7 @@ minetest.register_node("techage:oiltank", {
peek = liquid.srv_peek,
put = put_liquid,
take = take_liquid,
untake = untake_liquid,
},
networks = networks_def,
on_rightclick = on_rightclick,
@ -216,6 +227,7 @@ minetest.register_node("techage:ta4_tank", {
peek = liquid.srv_peek,
put = put_liquid,
take = take_liquid,
untake = untake_liquid,
},
networks = networks_def,
on_rightclick = on_rightclick,