From 21d583b7dde922947c5250c17aa522fb02a4127d Mon Sep 17 00:00:00 2001 From: Michal Cieslakiewicz Date: Thu, 26 Nov 2020 15:18:38 +0100 Subject: [PATCH] electrolyzer: add untake handler Without this method (which shares code with 'put') hydrogen from electrolyzer is removed and disappear when connected via pump to full destination device (tank, fuel cell etc). Signed-off-by: Michal Cieslakiewicz --- hydrogen/electrolyzer.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/hydrogen/electrolyzer.lua b/hydrogen/electrolyzer.lua index b83d4eb..2efcf25 100644 --- a/hydrogen/electrolyzer.lua +++ b/hydrogen/electrolyzer.lua @@ -156,6 +156,15 @@ local function after_dig_node(pos, oldnode, oldmetadata, digger) Cable:after_dig_node(pos) end +local function put(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", formspec(State, pos, nvm)) + end + return leftover +end + local function tubelib2_on_update2(pos, outdir, tlib2, node) if tlib2.tube_type == "pipe2" then liquid.update_network(pos, outdir, tlib2) @@ -182,14 +191,8 @@ local netw_def = { local liquid_def = { capa = CAPACITY, peek = liquid.srv_peek, - put = function(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", formspec(State, pos, nvm)) - end - return leftover - end, + put = put, + untake = put, take = function(pos, indir, name, amount) amount, name = liquid.srv_take(pos, indir, name, amount) if techage.is_activeformspec(pos) then