From 67507d008b14f553165e9b73e2cf8a84f71bfaa1 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Wed, 14 Oct 2020 19:11:20 +0200 Subject: [PATCH] Fix doorcontroller and ta4 doser bugs --- basis/lib.lua | 8 ++++++++ chemistry/ta4_doser.lua | 11 +++++++++++ liquids/node_api.lua | 2 +- logic/doorcontroller.lua | 7 +++---- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/basis/lib.lua b/basis/lib.lua index 9d954c4..29b4657 100644 --- a/basis/lib.lua +++ b/basis/lib.lua @@ -126,6 +126,14 @@ function techage.is_primary_node(pos, dir) return param2 ~= 0 end +function techage.is_air_like(name) + local ndef = minetest.registered_nodes[name] + if ndef and ndef.buildable_to then + return true + end + return false +end + -- returns true, if node can be dug, otherwise false function techage.can_node_dig(node, ndef) if RegisteredNodesToBeDug[node.name] then diff --git a/chemistry/ta4_doser.lua b/chemistry/ta4_doser.lua index 165316d..9f9f451 100644 --- a/chemistry/ta4_doser.lua +++ b/chemistry/ta4_doser.lua @@ -153,6 +153,15 @@ local State = techage.NodeStates:new({ stop_node = stop_node, }) +local function untake(recipe, pos, liquids) + for _,item in pairs(recipe.input) do + if item.name ~= "" then + local outdir = liquids[item.name] or reload_liquids(pos)[item.name] + liquid.untake(pos, outdir, item.name, item.num) + end + end +end + local function dosing(pos, nvm, elapsed) -- trigger reactor (power) if not reactor_cmnd(pos, "power") then @@ -215,6 +224,7 @@ local function dosing(pos, nvm, elapsed) name = recipe.output.name, amount = recipe.output.num}) if not leftover or (tonumber(leftover) or 1) > 0 then + untake(recipe, pos, liquids) State:blocked(pos, nvm) reactor_cmnd(pos, "stop") return @@ -224,6 +234,7 @@ local function dosing(pos, nvm, elapsed) name = recipe.waste.name, amount = recipe.waste.num}) if not leftover or (tonumber(leftover) or 1) > 0 then + untake(recipe, pos, liquids) State:blocked(pos, nvm) reactor_cmnd(pos, "stop") return diff --git a/liquids/node_api.lua b/liquids/node_api.lua index b6ec288..fe08e8b 100644 --- a/liquids/node_api.lua +++ b/liquids/node_api.lua @@ -162,7 +162,7 @@ function liquid.take(pos, outdir, name, amount, player_name) return taken, item_name end -function liquid.untake(pos, outdir, name, amount, player_name) +function liquid.untake(pos, outdir, name, amount) for _,item in ipairs(get_network_table(pos, outdir, "tank")) do local liquid = LQD(item.pos) if liquid and liquid.untake then diff --git a/logic/doorcontroller.lua b/logic/doorcontroller.lua index b670755..489f152 100644 --- a/logic/doorcontroller.lua +++ b/logic/doorcontroller.lua @@ -49,13 +49,12 @@ local function swap_door_nodes(pos, open) if open then if node.name == item.name then minetest.remove_node(item.pos) + item.removed = true else - item.name = nil + item.removed = false end - elseif node.name == "air" then + elseif techage.is_air_like(node.name) and item.removed then minetest.add_node(item.pos, {name = item.name, param2 = item.param2}) - else - minetest.add_item(pos, item.pos, {name = item.name}) end end end