From 8020eb1863c7ccfd925267b9132116f98ee4cca5 Mon Sep 17 00:00:00 2001
From: benrob0329 <ben@innovationplex.com>
Date: Sun, 9 Jun 2019 14:50:10 -0400
Subject: [PATCH] Add mesecons support to doors (#106)

(if available)
---
 depends.txt   |  3 ++-
 src/nodes.lua | 22 +++++++++++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/depends.txt b/depends.txt
index 49669a2..5ea4cb6 100644
--- a/depends.txt
+++ b/depends.txt
@@ -5,4 +5,5 @@ stairs
 xpanes
 fire?
 oresplus?
-moreblocks?
\ No newline at end of file
+moreblocks?
+mesecons_doors?
diff --git a/src/nodes.lua b/src/nodes.lua
index 20bd72e..969a803 100644
--- a/src/nodes.lua
+++ b/src/nodes.lua
@@ -263,6 +263,25 @@ local xdecor_doors = {
 		{"group:wood", "group:wood"} }
 }
 
+local mesecons_register
+if minetest.global_exists("mesecon") then
+	mesecons_register = { effector = {
+		action_on = function(pos, node)
+			local door = doors.get(pos)
+			if door then
+				door:open()
+			end
+		end,
+		action_off = function(pos, node)
+			local door = doors.get(pos)
+			if door then
+				door:close()
+			end
+		end,
+		rules = mesecon.rules.pplate
+	}}
+end
+
 for name, recipe in pairs(xdecor_doors) do
 	if not doors.register then break end
 	doors.register(name.."_door", {
@@ -271,7 +290,8 @@ for name, recipe in pairs(xdecor_doors) do
 		inventory_image = "xdecor_"..name.."_door_inv.png",
 		protected = door_access(name),
 		groups = {choppy=2, cracky=2, oddly_breakable_by_hand=1, door=1},
-		recipe = recipe
+		recipe = recipe,
+		mesecons = mesecons_register
 	})
 end
 
-- 
GitLab