From 912f17f33590df4ad76775a3511881ad4bbf4853 Mon Sep 17 00:00:00 2001 From: Carter Kolwey Date: Tue, 23 Aug 2016 00:20:46 -0500 Subject: Split wires into their own mod, introduce autoconnect hooks The update_autoconnect function had to be abstracted away from the default wires, any kind of wire can now register autoconnect hooks, which should make having multiple different wire types much easier. mesecons_mvps, mesecons_receiver and mesecons_random made use of update_autoconnect, their code was also adapted. This also fixes a receiver bug: If a receiver was placed with a onstate receptor next to it (but not the wall lever / button that caused the receiver to appear) the receiver didn't turn on in the past. Also move documentation for mesecon wire into mesecons_wire. --- mesecons_receiver/init.lua | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'mesecons_receiver') diff --git a/mesecons_receiver/init.lua b/mesecons_receiver/init.lua index 36f4659..9284e57 100644 --- a/mesecons_receiver/init.lua +++ b/mesecons_receiver/init.lua @@ -104,13 +104,8 @@ function mesecon.receiver_place(rcpt_pos) if string.find(nn.name, "mesecons:wire_") ~= nil then minetest.dig_node(pos) - if mesecon.is_power_on(rcpt_pos) then - minetest.set_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2}) - mesecon.receptor_on(pos, receiver_get_rules(node)) - else - minetest.set_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2}) - end - mesecon.update_autoconnect(pos) + minetest.set_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2}) + mesecon.on_placenode(pos, nn) end end @@ -121,7 +116,6 @@ function mesecon.receiver_remove(rcpt_pos, dugnode) minetest.dig_node(pos) local node = {name = "mesecons:wire_00000000_off"} minetest.set_node(pos, node) - mesecon.update_autoconnect(pos) mesecon.on_placenode(pos, node) end end -- cgit v1.2.3