From 23475196960f294685c3c315a00122cde9517b7f Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Thu, 18 Nov 2021 19:25:54 -0500 Subject: [PATCH] Merge two conditions into one --- mesecons/internal.lua | 50 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/mesecons/internal.lua b/mesecons/internal.lua index 0d65d27..165c001 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -383,35 +383,33 @@ local function find_light_update_conductors() local checked = {} for name, def in pairs(minetest.registered_nodes) do local conductor = mesecon.get_conductor(name) - if conductor then - if not checked[name] then - -- Find the other states of the conductor besides the current one. - local other_states - if conductor.onstate then - other_states = {conductor.onstate} - elseif conductor.offstate then - other_states = {conductor.offstate} - else - other_states = conductor.states - end + if conductor and not checked[name] then + -- Find the other states of the conductor besides the current one. + local other_states + if conductor.onstate then + other_states = {conductor.onstate} + elseif conductor.offstate then + other_states = {conductor.offstate} + else + other_states = conductor.states + end - -- Check the conductor. Other states are marked as checked. - for _, other_state in ipairs(other_states) do - local other_def = minetest.registered_nodes[other_state] - if (def.paramtype == "light") ~= (other_def.paramtype == "light") - or def.sunlight_propagates ~= other_def.sunlight_propagates - or def.light_source ~= other_def.light_source then - -- The light characteristics change depending on the state. - -- The states are added to the set. - light_update_conductors[name] = true - for _, other_state in ipairs(other_states) do - light_update_conductors[other_state] = true - checked[other_state] = true - end - break + -- Check the conductor. Other states are marked as checked. + for _, other_state in ipairs(other_states) do + local other_def = minetest.registered_nodes[other_state] + if (def.paramtype == "light") ~= (other_def.paramtype == "light") + or def.sunlight_propagates ~= other_def.sunlight_propagates + or def.light_source ~= other_def.light_source then + -- The light characteristics change depending on the state. + -- The states are added to the set. + light_update_conductors[name] = true + for _, other_state in ipairs(other_states) do + light_update_conductors[other_state] = true + checked[other_state] = true end - checked[other_state] = true + break end + checked[other_state] = true end end end