From 18cae761afa7a979929176f401b204418fae5971 Mon Sep 17 00:00:00 2001 From: RealBadAngel Date: Sun, 27 Apr 2014 15:57:11 +0200 Subject: [PATCH] The code to connect an electrical machine to cables would only consider the first-seen tier for which the machine was registered. So the switching station, which is uniquely registered for all tiers, would only visually connect to LV cable when placed, not to MV or HV cable. (It would function nevertheless, and cable would connect to the switching station if placed later.) Change to consider all tiers. Incidentally avoid a gratuitous iteration through all registered machines. --- technic/machines/register/cables.lua | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/technic/machines/register/cables.lua b/technic/machines/register/cables.lua index 3bf2208..4f7dcf5 100644 --- a/technic/machines/register/cables.lua +++ b/technic/machines/register/cables.lua @@ -62,12 +62,9 @@ end minetest.register_on_placenode(function(pos, node) for tier, machine_list in pairs(technic.machines) do - for machine_name, _ in pairs(machine_list) do - if node.name == machine_name then - technic.update_cables(pos, tier, true) - technic.networks = {} - return - end + if machine_list[node.name] ~= nil then + technic.update_cables(pos, tier, true) + technic.networks = {} end end end) @@ -75,12 +72,9 @@ end) minetest.register_on_dignode(function(pos, node) for tier, machine_list in pairs(technic.machines) do - for machine_name, _ in pairs(machine_list) do - if node.name == machine_name then - technic.update_cables(pos, tier, true) - technic.networks = {} - return - end + if machine_list[node.name] ~= nil then + technic.update_cables(pos, tier, true) + technic.networks = {} end end end)