From d3b77b5be33b7103b5fe3fc07246c903b02b2d90 Mon Sep 17 00:00:00 2001
From: Jeija <norrepli@gmail.com>
Date: Thu, 27 Dec 2012 12:03:05 +0100
Subject: [PATCH] Compatibility with old pistons

---
 mesecons_alias/init.lua   |  8 +++++++-
 mesecons_pistons/init.lua | 19 +++++++++----------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/mesecons_alias/init.lua b/mesecons_alias/init.lua
index eaebbc6..395c368 100644
--- a/mesecons_alias/init.lua
+++ b/mesecons_alias/init.lua
@@ -11,7 +11,7 @@ minetest.register_alias("mesecons:wireless_receiver", "mesecons_wireless:wireles
 minetest.register_alias("mesecons:wireless_transmitter", "mesecons_wireless:wireless_transmitter_off")
 minetest.register_alias("mesecons:switch", "mesecons_switch:mesecon_switch_off")
 minetest.register_alias("mesecons:button", "mesecons_button:button_off")
-minetest.register_alias("mesecons:piston", "mesecons_pistons:piston_normal")
+minetest.register_alias("mesecons:piston", "mesecons_pistons:piston_normal_off")
 minetest.register_alias("mesecons:blinky_plant", "mesecons_blinkyplant:blinky_plant_off")
 minetest.register_alias("mesecons:mesecon_torch", "mesecons_torch:mesecon_torch_on")
 minetest.register_alias("mesecons:torch", "mesecons_torch:mesecon_torch_on")
@@ -30,3 +30,9 @@ minetest.register_alias("mesecons:solarpanel", "mesecons_solarpanel:solar_panel_
 
 --Backwards compatibility
 minetest.register_alias("mesecons:mesecon_off", "mesecons:wire_00000000_off")
+minetest.register_alias("mesecons_pistons:piston_sticky", "mesecons_pistons:piston_sticky_on")
+minetest.register_alias("mesecons_pistons:piston_normal", "mesecons_pistons:piston_normal_on")
+minetest.register_alias("mesecons_pistons:piston_up_normal", "mesecons_pistons:piston_up_normal_on")
+minetest.register_alias("mesecons_pistons:piston_down_normal", "mesecons_pistons:piston_down_normal_on")
+minetest.register_alias("mesecons_pistons:piston_up_sticky", "mesecons_pistons:piston_up_sticky_on")
+minetest.register_alias("mesecons_pistons:piston_down_sticky", "mesecons_pistons:piston_down_sticky_on")
diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua
index 75547d2..828b466 100644
--- a/mesecons_pistons/init.lua
+++ b/mesecons_pistons/init.lua
@@ -1,8 +1,3 @@
---
---
---
---
-
 -- Get mesecon rules of pistons
 piston_rules =
 {{x=0,  y=0,  z=1}, --everything apart from z- (pusher side)
@@ -44,8 +39,12 @@ local piston_remove_pusher = function (pos, node)
 
 	dir = piston_get_direction(pistonspec.dir, node)
 	local pusherpos = mesecon:addPosRule(pos, dir)
-	minetest.env:remove_node(pusherpos)
-	nodeupdate(pusherpos)
+	local pushername = minetest.env:get_node(pusherpos).name
+
+	if pushername == pistonspec.pusher then --make sure there actually is a pusher (for compatibility reasons mainly)
+		minetest.env:remove_node(pusherpos)
+		nodeupdate(pusherpos)
+	end
 end
 
 local piston_on = function (pos, node)
@@ -252,7 +251,7 @@ local piston_up_on_box = {
 
 -- Normal
 
-local pistonspec_normal_down = {
+local pistonspec_normal_up = {
 	offname = "mesecons_pistons:piston_up_normal_off",
 	onname = "mesecons_pistons:piston_up_normal_on",
 	dir = {x = 0, y = 1, z = 0},
@@ -265,7 +264,7 @@ minetest.register_node("mesecons_pistons:piston_up_normal_off", {
 	groups = {cracky = 3, not_in_creative_inventory = 1},
 	paramtype2 = "facedir",
 	drop = {"mesecons_pistons:piston_normal_off"},
-	mesecons_piston = pistonspec_normal_down,
+	mesecons_piston = pistonspec_normal_up,
 	mesecons = {effector={
 		action_on = piston_on,
 	}}
@@ -282,7 +281,7 @@ minetest.register_node("mesecons_pistons:piston_up_normal_on", {
 	after_dig_node = piston_remove_pusher,
 	node_box = piston_up_on_box,
 	selection_box = piston_up_on_box,
-	mesecons_piston = pistonspec_normal_down,
+	mesecons_piston = pistonspec_normal_up,
 	mesecons = {effector={
 		action_off = piston_off,
 	}}
-- 
GitLab