From 49350278c08f2727a2535d2106adf8f421a47067 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Fri, 23 Jul 2021 19:21:46 +0200 Subject: [PATCH] Some bugfixes --- energy_storage/heatexchanger2.lua | 2 +- hydrogen/fuelcell.lua | 1 + power/formspecs.lua | 15 ++++++++++++--- solar/inverter.lua | 3 ++- wind_turbine/rotor.lua | 15 ++++++++------- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/energy_storage/heatexchanger2.lua b/energy_storage/heatexchanger2.lua index eb09337..1cb7c9f 100644 --- a/energy_storage/heatexchanger2.lua +++ b/energy_storage/heatexchanger2.lua @@ -84,7 +84,7 @@ local function can_start(pos, nvm) if diameter then nvm.capa_max = PWR_CAPA[tonumber(diameter)] or 0 if nvm.capa_max ~= 0 then - nvm.capa = math.min(nvm.capa, nvm.capa_max) + nvm.capa = math.min(nvm.capa or 0, nvm.capa_max) local owner = M(pos):get_string("owner") or "" return heatexchanger1_cmnd(pos, "volume", owner) else diff --git a/hydrogen/fuelcell.lua b/hydrogen/fuelcell.lua index f30209d..6fabbab 100644 --- a/hydrogen/fuelcell.lua +++ b/hydrogen/fuelcell.lua @@ -85,6 +85,7 @@ end local function stop_node(pos, nvm, state) nvm.provided = 0 + nvm.running = nil -- legacy local outdir = M(pos):get_int("outdir") power.start_storage_calc(pos, Cable, outdir) end diff --git a/power/formspecs.lua b/power/formspecs.lua index bb05264..c014ab5 100644 --- a/power/formspecs.lua +++ b/power/formspecs.lua @@ -213,7 +213,7 @@ function techage.generator_settings(tier, available) }, { type = "dropdown", - choices = "40% - 60%,60% - 80%,80% - 100%", + choices = "0% - 20%,20% - 40%,40% - 60%,60% - 80%,80% - 100%,90% - 100%", name = "termpoint", label = S("Charge termination"), tooltip = S("Range in which the generator reduces its power"), @@ -237,7 +237,7 @@ function techage.generator_settings(tier, available) }, { type = "dropdown", - choices = "40% - 60%,60% - 80%,80% - 100%", + choices = "0% - 20%,20% - 40%,40% - 60%,60% - 80%,80% - 100%,90% - 100%", name = "termpoint", label = S("Charge termination"), tooltip = S("Range in which the generator reduces its power"), @@ -250,7 +250,13 @@ end function techage.evaluate_charge_termination(nvm, meta) local termpoint = meta:get_string("termpoint") - if termpoint == "40% - 60%" then + if termpoint == "0% - 20%" then + meta:set_string("termpoint1", 0.0) + meta:set_string("termpoint2", 0.2) + elseif termpoint == "20% - 40%" then + meta:set_string("termpoint1", 0.2) + meta:set_string("termpoint2", 0.4) + elseif termpoint == "40% - 60%" then meta:set_string("termpoint1", 0.4) meta:set_string("termpoint2", 0.6) elseif termpoint == "60% - 80%" then @@ -259,6 +265,9 @@ function techage.evaluate_charge_termination(nvm, meta) elseif termpoint == "80% - 100%" then meta:set_string("termpoint1", 0.8) meta:set_string("termpoint2", 1.0) + elseif termpoint == "90% - 100%" then + meta:set_string("termpoint1", 0.9) + meta:set_string("termpoint2", 1.0) else meta:set_string("termpoint", "80% - 100%") meta:set_string("termpoint1", 0.8) diff --git a/solar/inverter.lua b/solar/inverter.lua index f2c5eb9..d22afc0 100644 --- a/solar/inverter.lua +++ b/solar/inverter.lua @@ -30,7 +30,7 @@ local COUNTDOWN_TICKS = 1 local function determine_power(pos, nvm) -- determine DC node position local outdir = M(pos):get_int("leftdir") - local netw = networks.get_network_table(pos, Solar, outdir, true) or {} + local netw = networks.get_network_table(pos, Solar, outdir) or {} local num_inv = #(netw.con or {}) local max_power = 0 for _, power in ipairs(control.request(pos, Solar, outdir, "junc", "power")) do @@ -100,6 +100,7 @@ end local function stop_node(pos, nvm, state) nvm.provided = 0 + nvm.running = nil -- legacy local outdir = M(pos):get_int("outdir") power.start_storage_calc(pos, Cable, outdir) end diff --git a/wind_turbine/rotor.lua b/wind_turbine/rotor.lua index 59a296c..97a6b26 100644 --- a/wind_turbine/rotor.lua +++ b/wind_turbine/rotor.lua @@ -81,14 +81,15 @@ end local function add_rotor(pos, nvm, force) if (force and not nvm.error) or check_rotor(pos, nvm) then local hash = minetest.hash_node_position(pos) - if not Rotors[hash] then - local node = minetest.get_node(pos) - local npos, yaw = pos_and_yaw(pos, node.param2) - local obj = minetest.add_entity(npos, "techage:rotor_ent") - obj:set_animation({x = 0, y = 119}, 0, 0, true) - obj:set_rotation(yaw) - Rotors[hash] = obj + if Rotors[hash] then + Rotors[hash]:remove() end + local node = minetest.get_node(pos) + local npos, yaw = pos_and_yaw(pos, node.param2) + local obj = minetest.add_entity(npos, "techage:rotor_ent") + obj:set_animation({x = 0, y = 119}, 0, 0, true) + obj:set_rotation(yaw) + Rotors[hash] = obj end end