Fix 'delivered' command for ta4 heat exchanger

This commit is contained in:
Joachim Stolberg 2021-09-10 20:23:33 +02:00
parent 17a39387b7
commit e73124fd38
2 changed files with 3 additions and 2 deletions

View File

@ -283,7 +283,8 @@ techage.register_node({"techage:heatexchanger2"}, {
return "stopped"
end
elseif topic == "delivered" then
return -math.max(nvm.needed or 0, 0)
local data = power.get_network_data(pos, Cable, DOWN)
return data.consumed - data.provided
elseif topic == "load" then
return techage.power.percent(nvm.capa_max, nvm.capa)
elseif topic == "on" then

View File

@ -38,7 +38,7 @@ local function round(val)
end
local function calc_percent(max_val, curr_val)
return math.min(((curr_val or 0) * 100) / (max_val or 1.0), 100)
return round(math.min(((curr_val or 0) * 100) / (max_val or 1.0), 100))
end
-------------------------------------------------------------------------------