diff --git a/liquids/node_api.lua b/liquids/node_api.lua index 1c4eb1c..7a6484c 100644 --- a/liquids/node_api.lua +++ b/liquids/node_api.lua @@ -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 -- diff --git a/liquids/pump.lua b/liquids/pump.lua index e8081b7..a01c36e 100644 --- a/liquids/pump.lua +++ b/liquids/pump.lua @@ -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 diff --git a/liquids/silo.lua b/liquids/silo.lua index fd0cd73..617bbfe 100644 --- a/liquids/silo.lua +++ b/liquids/silo.lua @@ -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 = { diff --git a/liquids/tank.lua b/liquids/tank.lua index 9663653..9144add 100644 --- a/liquids/tank.lua +++ b/liquids/tank.lua @@ -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,