summaryrefslogtreecommitdiff
path: root/mesecons
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2016-08-27 02:29:09 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2016-08-27 02:29:09 -0400
commit7a63e51fb5ac8c2db1bda58a2ba7e8532356fc8e (patch)
tree7fe5b4d84762c5280d68bc4aa3a36517b29d522f /mesecons
parent959353cce593366168f7ce3bba393fe2ee0e522d (diff)
downloaddreambuilder_modpack-7a63e51fb5ac8c2db1bda58a2ba7e8532356fc8e.tar
dreambuilder_modpack-7a63e51fb5ac8c2db1bda58a2ba7e8532356fc8e.tar.gz
dreambuilder_modpack-7a63e51fb5ac8c2db1bda58a2ba7e8532356fc8e.tar.bz2
dreambuilder_modpack-7a63e51fb5ac8c2db1bda58a2ba7e8532356fc8e.tar.xz
dreambuilder_modpack-7a63e51fb5ac8c2db1bda58a2ba7e8532356fc8e.zip
updated mesecons and Jordach's player skin
Diffstat (limited to 'mesecons')
-rw-r--r--mesecons/init.lua3
-rw-r--r--mesecons/services.lua11
-rw-r--r--mesecons/textures/jeija_close_window.pngbin0 -> 323 bytes
-rw-r--r--mesecons/textures/jeija_microcontroller_bottom.pngbin0 -> 550 bytes
-rw-r--r--mesecons/textures/jeija_microcontroller_sides.pngbin0 -> 613 bytes
-rw-r--r--mesecons/util.lua31
6 files changed, 36 insertions, 9 deletions
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..1abbc0c 100644
--- a/mesecons/services.lua
+++ b/mesecons/services.lua
@@ -1,7 +1,7 @@
-- Dig and place services
-mesecon.on_placenode = function (pos, node)
- mesecon.update_autoconnect(pos, node)
+mesecon.on_placenode = function(pos, node)
+ mesecon.execute_autoconnect_hooks_now(pos, node)
-- Receptors: Send on signal when active
if mesecon.is_receptor_on(node.name) then
@@ -52,16 +52,15 @@ mesecon.on_placenode = function (pos, node)
end
end
-mesecon.on_dignode = function (pos, node)
+mesecon.on_dignode = function(pos, node)
if mesecon.is_conductor_on(node) then
mesecon.receptor_off(pos, mesecon.conductor_get_rules(node))
elseif mesecon.is_receptor_on(node.name) then
mesecon.receptor_off(pos, mesecon.receptor_get_rules(node))
end
- mesecon.queue:add_action(pos, "update_autoconnect", {node})
-end
-mesecon.queue:add_function("update_autoconnect", mesecon.update_autoconnect)
+ mesecon.execute_autoconnect_hooks_queue(pos, node)
+end
minetest.register_on_placenode(mesecon.on_placenode)
minetest.register_on_dignode(mesecon.on_dignode)
diff --git a/mesecons/textures/jeija_close_window.png b/mesecons/textures/jeija_close_window.png
new file mode 100644
index 0000000..5c27c6c
--- /dev/null
+++ b/mesecons/textures/jeija_close_window.png
Binary files differ
diff --git a/mesecons/textures/jeija_microcontroller_bottom.png b/mesecons/textures/jeija_microcontroller_bottom.png
new file mode 100644
index 0000000..3a9161e
--- /dev/null
+++ b/mesecons/textures/jeija_microcontroller_bottom.png
Binary files differ
diff --git a/mesecons/textures/jeija_microcontroller_sides.png b/mesecons/textures/jeija_microcontroller_sides.png
new file mode 100644
index 0000000..b367644
--- /dev/null
+++ b/mesecons/textures/jeija_microcontroller_sides.png
Binary files differ
diff --git a/mesecons/util.lua b/mesecons/util.lua
index 3827dce..d95f216 100644
--- a/mesecons/util.lua
+++ b/mesecons/util.lua
@@ -273,3 +273,34 @@ mesecon.forceloaded_blocks = mesecon.file2table("mesecon_forceloaded")
minetest.register_on_shutdown(function()
mesecon.table2file("mesecon_forceloaded", mesecon.forceloaded_blocks)
end)
+
+-- Autoconnect Hooks
+-- Nodes like conductors may change their appearance and their connection rules
+-- right after being placed or after being dug, e.g. the default wires use this
+-- to automatically connect to linking nodes after placement.
+-- After placement, the update function will be executed immediately so that the
+-- possibly changed rules can be taken into account when recalculating the circuit.
+-- After digging, the update function will be queued and executed after
+-- recalculating the circuit. The update function must take care of updating the
+-- node at the given position itself, but also all of the other nodes the given
+-- position may have (had) a linking connection to.
+mesecon.autoconnect_hooks = {}
+
+-- name: A unique name for the hook, e.g. "foowire". Used to name the actionqueue function.
+-- fct: The update function with parameters function(pos, node)
+function mesecon.register_autoconnect_hook(name, fct)
+ mesecon.autoconnect_hooks[name] = fct
+ mesecon.queue:add_function("autoconnect_hook_"..name, fct)
+end
+
+function mesecon.execute_autoconnect_hooks_now(pos, node)
+ for _, fct in pairs(mesecon.autoconnect_hooks) do
+ fct(pos, node)
+ end
+end
+
+function mesecon.execute_autoconnect_hooks_queue(pos, node)
+ for name in pairs(mesecon.autoconnect_hooks) do
+ mesecon.queue:add_action(pos, "autoconnect_hook_"..name, {node})
+ end
+end