From 89214caa1cc9e22d15c1b6505a7f26eb68bacce9 Mon Sep 17 00:00:00 2001 From: Carter Kolwey Date: Tue, 23 Aug 2016 00:20:46 -0500 Subject: [PATCH] Split conductors into their own mod --- mesecons/init.lua | 3 --- mesecons/services.lua | 11 +++++++++-- mesecons_conductors/depends.txt | 1 + mesecons/wires.lua => mesecons_conductors/init.lua | 4 +++- 4 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 mesecons_conductors/depends.txt rename mesecons/wires.lua => mesecons_conductors/init.lua (98%) diff --git a/mesecons/init.lua b/mesecons/init.lua index 3ab4f4a..6b36e69 100644 --- a/mesecons/init.lua +++ b/mesecons/init.lua @@ -132,8 +132,5 @@ print("[OK] Mesecons") -- To be removed in future releases dofile(minetest.get_modpath("mesecons").."/legacy.lua"); ---The actual wires -dofile(minetest.get_modpath("mesecons").."/wires.lua"); - --Services like turnoff receptor on dignode and so on dofile(minetest.get_modpath("mesecons").."/services.lua"); diff --git a/mesecons/services.lua b/mesecons/services.lua index 343410a..3d4fcc6 100644 --- a/mesecons/services.lua +++ b/mesecons/services.lua @@ -1,5 +1,14 @@ -- Dig and place services +-- Stub to "fake" updating conductors if not installed +-- If it is installed, that mod handles these +if not minetest.get_modpath("mesecons_conductors") then + mesecon.update_autoconnect = function() + return + end + mesecon.queue:add_function("update_autoconnect", mesecon.update_autoconnect) +end + mesecon.on_placenode = function (pos, node) mesecon.update_autoconnect(pos, node) @@ -61,8 +70,6 @@ mesecon.on_dignode = function (pos, node) mesecon.queue:add_action(pos, "update_autoconnect", {node}) end -mesecon.queue:add_function("update_autoconnect", mesecon.update_autoconnect) - minetest.register_on_placenode(mesecon.on_placenode) minetest.register_on_dignode(mesecon.on_dignode) diff --git a/mesecons_conductors/depends.txt b/mesecons_conductors/depends.txt new file mode 100644 index 0000000..acaa924 --- /dev/null +++ b/mesecons_conductors/depends.txt @@ -0,0 +1 @@ +mesecons diff --git a/mesecons/wires.lua b/mesecons_conductors/init.lua similarity index 98% rename from mesecons/wires.lua rename to mesecons_conductors/init.lua index d77904e..40b6035 100644 --- a/mesecons/wires.lua +++ b/mesecons_conductors/init.lua @@ -96,6 +96,8 @@ function mesecon.update_autoconnect(pos, node) update_on_place_dig(pos, node) end +mesecon.queue:add_function("update_autoconnect", mesecon.update_autoconnect) + -- ############################ -- ## Wire node registration ## -- ############################ @@ -204,7 +206,7 @@ register_wires = function() groups_off["not_in_creative_inventory"] = 1 end - mesecon.register_node("mesecons:wire_"..nodeid, { + mesecon.register_node(":mesecons:wire_"..nodeid, { description = "Mesecon", drawtype = "nodebox", inventory_image = "mesecons_wire_inv.png",