From 34b6fd1b72b8c4e5fe6ac807006eee979c9e6a69 Mon Sep 17 00:00:00 2001 From: SomeName42 <> Date: Sat, 16 Nov 2024 09:31:56 +0100 Subject: [PATCH 1/3] Fixed power monitor instability where it was switching between having and not having network infotext. Resolves #640. The cause of the issue was that the power monitor is LV MV and HV machine at the same time, and each tier has a countdown. If any of these countdowns were 0 it treated the machine as having no network. This was changed so that it only treats a machine as having no network if it is timed out in all tiers that it is a part of. --- technic/machines/switching_station.lua | 33 ++++++++++++++++---------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua index 521e2f82..8ad23d52 100644 --- a/technic/machines/switching_station.lua +++ b/technic/machines/switching_station.lua @@ -468,20 +468,27 @@ minetest.register_abm({ interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) + local has_network = false + local technic_machine = false for tier, machines in pairs(technic.machines) do - if machines[node.name] and switching_station_timeout_count(pos, tier) then - local nodedef = minetest.registered_nodes[node.name] - if nodedef then - local meta = minetest.get_meta(pos) - meta:set_string("infotext", S("%s Has No Network"):format(nodedef.description)) - end - if nodedef and nodedef.technic_disabled_machine_name then - node.name = nodedef.technic_disabled_machine_name - minetest.swap_node(pos, node) - end - if nodedef and nodedef.technic_on_disable then - nodedef.technic_on_disable(pos, node) - end + if machines[node.name] then + technic_machine = true + has_network = has_network or not switching_station_timeout_count(pos, tier) + end + end + + if technic_machine and not has_network then + local nodedef = minetest.registered_nodes[node.name] + if nodedef then + local meta = minetest.get_meta(pos) + meta:set_string("infotext", S("%s Has No Network"):format(nodedef.description)) + end + if nodedef and nodedef.technic_disabled_machine_name then + node.name = nodedef.technic_disabled_machine_name + minetest.swap_node(pos, node) + end + if nodedef and nodedef.technic_on_disable then + nodedef.technic_on_disable(pos, node) end end end, From 415c33001c1bc8b9acf502c0fdaed04ec16b35b9 Mon Sep 17 00:00:00 2001 From: SomeName42 <> Date: Sat, 16 Nov 2024 10:39:00 +0100 Subject: [PATCH 2/3] Made timeout update when a different tier network already found. --- technic/machines/switching_station.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua index 8ad23d52..1b25b64f 100644 --- a/technic/machines/switching_station.lua +++ b/technic/machines/switching_station.lua @@ -473,7 +473,9 @@ minetest.register_abm({ for tier, machines in pairs(technic.machines) do if machines[node.name] then technic_machine = true - has_network = has_network or not switching_station_timeout_count(pos, tier) + if not switching_station_timeout_count(pos, tier) then + has_network = true + end end end From a8bf56d984b2dc68b5ad86de3401ba503a7a88ce Mon Sep 17 00:00:00 2001 From: SomeName42 <> Date: Sat, 16 Nov 2024 13:11:20 +0100 Subject: [PATCH 3/3] Removed unneccesary nodedef checks. --- technic/machines/switching_station.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua index 1b25b64f..d1cabf05 100644 --- a/technic/machines/switching_station.lua +++ b/technic/machines/switching_station.lua @@ -481,15 +481,13 @@ minetest.register_abm({ if technic_machine and not has_network then local nodedef = minetest.registered_nodes[node.name] - if nodedef then - local meta = minetest.get_meta(pos) - meta:set_string("infotext", S("%s Has No Network"):format(nodedef.description)) - end - if nodedef and nodedef.technic_disabled_machine_name then + local meta = minetest.get_meta(pos) + meta:set_string("infotext", S("%s Has No Network"):format(nodedef.description)) + if nodedef.technic_disabled_machine_name then node.name = nodedef.technic_disabled_machine_name minetest.swap_node(pos, node) end - if nodedef and nodedef.technic_on_disable then + if nodedef.technic_on_disable then nodedef.technic_on_disable(pos, node) end end