From 841bc70b97e237477b0dd9ba36fd9cd307daf581 Mon Sep 17 00:00:00 2001
From: Jeija <norrepli@gmail.com>
Date: Wed, 9 Jan 2013 16:56:25 +0100
Subject: [PATCH] Fix a bug that occured when using a receptor placed directly
 next to a gate. We need to call a changesignal even if the gate/other
 effector is still connected to a power source in a way.

---
 mesecons/init.lua       | 8 ++++++--
 mesecons_gates/init.lua | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/mesecons/init.lua b/mesecons/init.lua
index 011c96f..50ed4ca 100644
--- a/mesecons/init.lua
+++ b/mesecons/init.lua
@@ -94,8 +94,12 @@ function mesecon:receptor_off(pos, rules)
 	for _, rule in ipairs(rules) do
 		local np = mesecon:addPosRule(pos, rule)
 		local link, rulename = mesecon:rules_link(pos, np, rules)
-		if link and not mesecon:connected_to_receptor(np) then
-			mesecon:turnoff(np, rulename)
+		if link then
+			if not mesecon:connected_to_receptor(np) then
+				mesecon:turnoff(np, rulename)
+			else
+				mesecon:changesignal(np, minetest.env:get_node(np), rulename)
+			end
 		end
 	end
 end
diff --git a/mesecons_gates/init.lua b/mesecons_gates/init.lua
index f49da0b..0e3d934 100644
--- a/mesecons_gates/init.lua
+++ b/mesecons_gates/init.lua
@@ -99,7 +99,7 @@ gates = {
 {name = "xor"  , inputnumber = 2}}
 
 local onoff, drop, nodename, description, groups
-for i, gate in ipairs(gates) do
+for _, gate in ipairs(gates) do
 	if gate.inputnumber == 1 then
 		get_rules = gate_get_input_rules_oneinput
 	elseif gate.inputnumber == 2 then