-local path = minetest.get_modpath("redstone")
---dofile(path.."/functions.lua")
---dofile(path.."/wire.lua")
-dofile(path.."/torch.lua")
---dofile(path.."/lever.lua")
---dofile(path.."/button.lua")
---dofile(path.."/repeater.lua")
---dofile(path.."/light.lua")
---dofile(path.."/piston.lua")
---dofile(path.."/comparator.lua")
---dofile(path.."/craft.lua")
---dofile(path.."/ore.lua")
---dofile(path.."/inverter.lua")
---dofile(path.."/player_detector.lua")
---dofile(path.."/space_maker.lua")
---dofile(path.."/pressure_plate.lua")
+-- activators
+local n_pos
+local temp_pool
+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)
+ end
+ return
+ end
+ end
+ end
+ end
+ if activator_table[temp_pool.name].deactivate then
+ activator_table[temp_pool.name].deactivate(pos)
+ end
+ end
+end
+
+-- directional activators
+local n_pos
+local temp_pool
+local temp_pool2
+local input
+local ignore
+local directional_activator = function(pos)
+
+ ignore = false
+ input = nil
+ temp_pool2 = nil
+
+ temp_pool = pool[pos.x][pos.y][pos.z]
+
+ if not temp_pool then ignore = true end
+
+ if not ignore then
+ input = temp_pool.input
+ end
+
+ if not input then ignore = true end
+
+ if not ignore then
+ input = temp_pool.input
+ end
+
+ if not ignore and pool and pool[input.x] and pool[input.x][input.y] and pool[input.x][input.y][input.z] then
+ temp_pool2 = pool[input.x][input.y][input.z]
+ else
+ ignore = true
+ end
+
+ if not temp_pool2 then ignore = true end
+
+ if not ignore and ((temp_pool2.dust and temp_pool2.dust > 0) or (temp_pool2.torch and temp_pool2.directional_activator and temp_pool2.dir == temp_pool.dir) or
+ (not temp_pool2.directional_activator and temp_pool2.torch) or (temp_pool2.capacitor and temp_pool2.capacitor > 0)) then
+ if activator_table[temp_pool.name].activate then
+ activator_table[temp_pool.name].activate(pos)
+ return
+ end
+ return
+ end