Skip to content

Commit 87e512f

Browse files
authored
Fix power monitor instability (#654)
This fixes the power monitor instability where it was switching between having and not having network infotext. The cause 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.
1 parent 18df281 commit 87e512f

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

technic/machines/switching_station.lua

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -468,22 +468,29 @@ minetest.register_abm({
468468
interval = 1,
469469
chance = 1,
470470
action = function(pos, node, active_object_count, active_object_count_wider)
471+
local has_network = false
472+
local technic_machine = false
471473
for tier, machines in pairs(technic.machines) do
472-
if machines[node.name] and switching_station_timeout_count(pos, tier) then
473-
local nodedef = minetest.registered_nodes[node.name]
474-
if nodedef then
475-
local meta = minetest.get_meta(pos)
476-
meta:set_string("infotext", S("%s Has No Network"):format(nodedef.description))
477-
end
478-
if nodedef and nodedef.technic_disabled_machine_name then
479-
node.name = nodedef.technic_disabled_machine_name
480-
minetest.swap_node(pos, node)
481-
end
482-
if nodedef and nodedef.technic_on_disable then
483-
nodedef.technic_on_disable(pos, node)
474+
if machines[node.name] then
475+
technic_machine = true
476+
if not switching_station_timeout_count(pos, tier) then
477+
has_network = true
484478
end
485479
end
486480
end
481+
482+
if technic_machine and not has_network then
483+
local nodedef = minetest.registered_nodes[node.name]
484+
local meta = minetest.get_meta(pos)
485+
meta:set_string("infotext", S("%s Has No Network"):format(nodedef.description))
486+
if nodedef.technic_disabled_machine_name then
487+
node.name = nodedef.technic_disabled_machine_name
488+
minetest.swap_node(pos, node)
489+
end
490+
if nodedef.technic_on_disable then
491+
nodedef.technic_on_disable(pos, node)
492+
end
493+
end
487494
end,
488495
})
489496

0 commit comments

Comments
 (0)