From 7a63e51fb5ac8c2db1bda58a2ba7e8532356fc8e Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Sat, 27 Aug 2016 02:29:09 -0400 Subject: updated mesecons and Jordach's player skin --- mesecons/init.lua | 3 -- mesecons/services.lua | 11 ++++---- mesecons/textures/jeija_close_window.png | Bin 0 -> 323 bytes mesecons/textures/jeija_microcontroller_bottom.png | Bin 0 -> 550 bytes mesecons/textures/jeija_microcontroller_sides.png | Bin 0 -> 613 bytes mesecons/util.lua | 31 +++++++++++++++++++++ 6 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 mesecons/textures/jeija_close_window.png create mode 100644 mesecons/textures/jeija_microcontroller_bottom.png create mode 100644 mesecons/textures/jeija_microcontroller_sides.png (limited to 'mesecons') 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 Binary files /dev/null and b/mesecons/textures/jeija_close_window.png differ diff --git a/mesecons/textures/jeija_microcontroller_bottom.png b/mesecons/textures/jeija_microcontroller_bottom.png new file mode 100644 index 0000000..3a9161e Binary files /dev/null and b/mesecons/textures/jeija_microcontroller_bottom.png differ diff --git a/mesecons/textures/jeija_microcontroller_sides.png b/mesecons/textures/jeija_microcontroller_sides.png new file mode 100644 index 0000000..b367644 Binary files /dev/null and b/mesecons/textures/jeija_microcontroller_sides.png 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 -- cgit v1.2.3