From cf4db41d7032241e4a958c765417a4911bb6a308 Mon Sep 17 00:00:00 2001 From: oilboi <47129783+oilboi@users.noreply.github.com> Date: Wed, 1 Jul 2020 13:09:55 -0400 Subject: [PATCH] Fix crashing in very specific state --- mods/redstone/init.lua | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/mods/redstone/init.lua b/mods/redstone/init.lua index 1998fb4..f9875bf 100644 --- a/mods/redstone/init.lua +++ b/mods/redstone/init.lua @@ -235,24 +235,26 @@ local temp_pool2 local non_directional_activator = function(pos) if pool[pos.x] and pool[pos.x][pos.y] and pool[pos.x][pos.y][pos.z] then temp_pool = pool[pos.x][pos.y][pos.z] - for _,order in pairs(order) do - n_pos = add_vec(pos,order) - if pool[n_pos.x] and pool[n_pos.x][n_pos.y] and pool[n_pos.x][n_pos.y][n_pos.z] then - temp_pool2 = pool[n_pos.x][n_pos.y][n_pos.z] - if temp_pool2 then - if (not temp_pool2.directional_activator and temp_pool2.torch) or - (temp_pool2.dust and temp_pool2.dust > 0) or - (temp_pool2.torch_directional and vector.equals(temp_pool2.output, pos)) then - if activator_table[temp_pool.name].activate then - activator_table[temp_pool.name].activate(pos) + if temp_pool then + for _,order in pairs(order) do + n_pos = add_vec(pos,order) + if pool[n_pos.x] and pool[n_pos.x][n_pos.y] and pool[n_pos.x][n_pos.y][n_pos.z] then + temp_pool2 = pool[n_pos.x][n_pos.y][n_pos.z] + if temp_pool2 then + if (not temp_pool2.directional_activator and temp_pool2.torch) or + (temp_pool2.dust and temp_pool2.dust > 0) or + (temp_pool2.torch_directional and vector.equals(temp_pool2.output, pos)) then + if activator_table[temp_pool.name] and activator_table[temp_pool.name].activate then + activator_table[temp_pool.name].activate(pos) + end + return end - return end end + end + if activator_table[temp_pool.name] and activator_table[temp_pool.name].deactivate then + activator_table[temp_pool.name].deactivate(pos) end - end - if activator_table[temp_pool.name].deactivate then - activator_table[temp_pool.name].deactivate(pos) end end end -- 2.44.0