minor improvements

This commit is contained in:
Joachim Stolberg 2020-04-03 21:45:36 +02:00
parent 50d0ae4ebd
commit 22c561a6e2
4 changed files with 18 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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