From 22c561a6e22986cbb8e2875aa2cb19447edaff8d Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Fri, 3 Apr 2020 21:45:36 +0200 Subject: [PATCH] minor improvements --- basic_machines/consumer.lua | 2 +- basic_machines/ta4_chest.lua | 15 +++++++++++++-- liquids/pump.lua | 2 +- oil/reboiler.lua | 4 +++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/basic_machines/consumer.lua b/basic_machines/consumer.lua index 85a8c07..31483bc 100644 --- a/basic_machines/consumer.lua +++ b/basic_machines/consumer.lua @@ -63,7 +63,7 @@ end local function node_timer(pos, elapsed) local crd = CRD(pos) local nvm = techage.get_nvm(pos) - if crd.power_netw then + if crd.power_netw and techage.needs_power(nvm) then power.consumer_alive(pos, crd.power_netw, crd.cycle_time) end -- call the node timer routine diff --git a/basic_machines/ta4_chest.lua b/basic_machines/ta4_chest.lua index e6ea869..808f337 100644 --- a/basic_machines/ta4_chest.lua +++ b/basic_machines/ta4_chest.lua @@ -95,8 +95,18 @@ local function sort_in(inv, nvm, stack) return false end -local function get_item(nvm, item_name, count) +local function get_item(inv, nvm, item_name, count) local stack = {count = 0} + if not inv:is_empty("main") then + if item_name then + local taken = inv:remove_item("main", {name = item_name, count = count}) + if taken:get_count() > 0 then + return taken + end + else + return techage.get_items(inv, "main", count) + end + end for _,item in ipairs(nvm.inventory or {}) do if (item_name == nil and stack.name == nil) or item.name == item_name then local num = math.min(item.count, count - stack.count) @@ -310,7 +320,8 @@ minetest.register_node("techage:ta4_chest", { techage.register_node({"techage:ta4_chest"}, { on_pull_item = function(pos, in_dir, num, item_name) local nvm = techage.get_nvm(pos) - local res = get_item(nvm, item_name, num) + local inv = M(pos):get_inventory() + local res = get_item(inv, nvm, item_name, num) if techage.is_activeformspec(pos) then M(pos):set_string("formspec", formspec(pos)) end diff --git a/liquids/pump.lua b/liquids/pump.lua index 9f60133..edf8e74 100644 --- a/liquids/pump.lua +++ b/liquids/pump.lua @@ -69,7 +69,7 @@ local function pumping(pos, nvm, state, capa) local taken, name = liquid.take(pos, Flip[outdir], nil, capa, starter) if taken > 0 then local leftover = liquid.put(pos, outdir, name, taken, starter) - if leftover and leftover > 0 then + if leftover and leftover == taken then liquid.put(pos, Flip[outdir], name, leftover) state:blocked(pos, nvm) return diff --git a/oil/reboiler.lua b/oil/reboiler.lua index 28d7a76..a5c5ebf 100644 --- a/oil/reboiler.lua +++ b/oil/reboiler.lua @@ -106,7 +106,9 @@ local function node_timer(pos, elapsed) nvm.liquid = nvm.liquid or {} nvm.liquid.amount = nvm.liquid.amount or 0 - power.consumer_alive(pos, Cable, CYCLE_TIME) + if not nvm.error or nvm.error == 0 then + power.consumer_alive(pos, Cable, CYCLE_TIME) + end if nvm.liquid.amount >= 5 and nvm.liquid.name == "techage:oil_source" then nvm.liquid.amount = nvm.liquid.amount - 5