Skip to content

Commit a550323

Browse files
author
Jeija
committedNov 22, 2014
Fix compatibility with not yet updated mods that use mesecon:receptor_*
1 parent d19e975 commit a550323

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed
 

Diff for: ‎mesecons/init.lua

+4-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ dofile(minetest.get_modpath("mesecons").."/actionqueue.lua");
6666
-- like calling action_on/off/change
6767
dofile(minetest.get_modpath("mesecons").."/internal.lua");
6868

69-
-- Deprecated stuff
70-
-- To be removed in future releases
71-
-- Currently there is nothing here
72-
dofile(minetest.get_modpath("mesecons").."/legacy.lua");
73-
7469
-- API
7570
-- these are the only functions you need to remember
7671

@@ -133,6 +128,10 @@ end
133128

134129
print("[OK] Mesecons")
135130

131+
-- Deprecated stuff
132+
-- To be removed in future releases
133+
dofile(minetest.get_modpath("mesecons").."/legacy.lua");
134+
136135
--The actual wires
137136
dofile(minetest.get_modpath("mesecons").."/wires.lua");
138137

Diff for: ‎mesecons/legacy.lua

+26-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
1-
function mesecon:receptor_on(pos, rules)
2-
mesecon.receptor_on(pos, rules)
1+
-- Ugly hack to prevent breaking compatibility with other mods
2+
-- Just remove the following two functions to delete the hack, to be done when other mods have updated
3+
function mesecon.receptor_on(self, pos, rules)
4+
if (self.receptor_on) then
5+
print("[Mesecons] Warning: A mod with mesecon support called mesecon:receptor_on.")
6+
print("[Mesecons] If you are the programmer of this mod, please update it ")
7+
print("[Mesecons] to use mesecon.receptor_on instead. mesecon:* is deprecated")
8+
print("[Mesecons] Otherwise, please make sure you're running the latest version")
9+
print("[Mesecons] of that mod and inform the mod creator.")
10+
else
11+
rules = pos
12+
pos = self
13+
end
14+
mesecon.queue:add_action(pos, "receptor_on", {rules}, nil, rules)
315
end
416

5-
function mesecon:receptor_off(pos, rules)
6-
mesecon.receptor_off(pos, rules)
17+
function mesecon.receptor_off(self, pos, rules)
18+
if (self.receptor_off) then
19+
print("[Mesecons] Warning: A mod with mesecon support called mesecon:receptor_off.")
20+
print("[Mesecons] If you are the programmer of this mod, please update it ")
21+
print("[Mesecons] to use mesecon.receptor_off instead. mesecon:* is deprecated")
22+
print("[Mesecons] Otherwise, please make sure you're running the latest version")
23+
print("[Mesecons] of that mod and inform the mod creator.")
24+
else
25+
rules = pos
26+
pos = self
27+
end
28+
mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
729
end

Diff for: ‎mesecons_switch/init.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ minetest.register_node("mesecons_switch:mesecon_switch_off", {
1111
}},
1212
on_punch = function(pos, node)
1313
minetest.swap_node(pos, {name = "mesecons_switch:mesecon_switch_on", param2 = node.param2})
14-
mesecon.receptor_on(pos)
14+
mesecon:receptor_on(pos)
1515
minetest.sound_play("mesecons_switch", {pos=pos})
1616
end
1717
})
@@ -27,7 +27,7 @@ minetest.register_node("mesecons_switch:mesecon_switch_on", {
2727
}},
2828
on_punch = function(pos, node)
2929
minetest.swap_node(pos, {name = "mesecons_switch:mesecon_switch_off", param2 = node.param2})
30-
mesecon.receptor_off(pos)
30+
mesecon:receptor_off(pos)
3131
minetest.sound_play("mesecons_switch", {pos=pos})
3232
end
3333
})

0 commit comments

Comments
 (0)
Please sign in to comment.