From d86da768aa3ae760f1c3313809a7aedd03456f90 Mon Sep 17 00:00:00 2001 From: paly2 Date: Thu, 17 Dec 2015 12:56:12 +0100 Subject: [PATCH] Change the signal changer --- README.md | 2 +- moremesecons_signalchanger/init.lua | 15 ++++++++++----- .../textures/moremesecons_signalchanger_off.png | Bin 112 -> 149 bytes .../textures/moremesecons_signalchanger_on.png | Bin 115 -> 149 bytes 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index cff33c1..cb95968 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ MoreMesecons is a mod for minetest wich adds some mesecons items. * `Injector Controller` : This node is usefull to activate/deactivate a pipeworks filter injector : it sends a blinky signal. * `Player Killer` : This block kills the nearest player (with a maximal distance of 8 blocks by default) (if this player isn't its owner) when it receives a mesecons signal. * `Sayer` : This node sends a message to every players inside a radius of 8 nodes. -* `Signal Changer` : If it receives a signal on its pin "F", it turns on. If it receives a signal on its pin "O", it turns off. +* `Signal Changer` : If it receives a signal on its pin "F", it turns on. If it receives a signal on its pin "O", it turns off. Note : an inverted signal is sended at the other end of the arrow. * `Switch Torch` : It connects just like Mesecons Torch. If it receives a signal, it turns on, and if it receives a second signal, it turns off. * `Teleporter` : If you place one teleporter, if it receives a mesecons, it teleports the nearest player on itself. If you place two teleporters on the same axis, if one receives a mesecons signal, it teleports the nearest player on the second (with a maximal distance of 50 nodes by default). The player teleporter must be inside a radius of 25 nodes. * `Temporary Gate` : If it receives a mesecons signal, whatever its duration, a mesecons signal is send with a fixed duration. You can change it by right-click (in seconds) (you can write for example 0.2 to send a pulse, or 20 to send long signals). diff --git a/moremesecons_signalchanger/init.lua b/moremesecons_signalchanger/init.lua index 3d7a4a3..61a5627 100644 --- a/moremesecons_signalchanger/init.lua +++ b/moremesecons_signalchanger/init.lua @@ -4,7 +4,8 @@ local nodebox = { } local function signalchanger_get_output_rules(node) - local rules = {{x=1, y=0, z=0}} + local rules = {{x=1, y=0, z=0}, + {x=-1, y=0, z=0}} for i = 0, node.param2 do rules = mesecon.rotate_rules_left(rules) end @@ -25,10 +26,12 @@ local update = function(pos, node, link, newstate) local input_on = meta:get_int("input_on") == 1 local input_off = meta:get_int("input_off") == 1 if input_on then - mesecon.receptor_on(pos, signalchanger_get_output_rules(node)) + mesecon.receptor_on(pos, {signalchanger_get_output_rules(node)[1]}) + mesecon.receptor_off(pos, {signalchanger_get_output_rules(node)[2]}) minetest.swap_node(pos, {name = "moremesecons_signalchanger:signalchanger_on", param2 = node.param2}) elseif input_off then - mesecon.receptor_off(pos, signalchanger_get_output_rules(node)) + mesecon.receptor_off(pos, {signalchanger_get_output_rules(node)[1]}) + mesecon.receptor_on(pos, {signalchanger_get_output_rules(node)[2]}) minetest.swap_node(pos, {name = "moremesecons_signalchanger:signalchanger_off", param2 = node.param2}) end end @@ -46,7 +49,6 @@ mesecon.register_node("moremesecons_signalchanger:signalchanger", { groups = {dig_immediate = 2}, mesecons = { receptor = { - state = mesecon.state.off, rules = signalchanger_get_output_rules }, effector = { @@ -55,11 +57,14 @@ mesecon.register_node("moremesecons_signalchanger:signalchanger", { }, }, tiles = {"moremesecons_signalchanger_off.png"}, + on_construct = function(pos) + local node = minetest.get_node(pos) + mesecon.receptor_on(pos, {signalchanger_get_output_rules(node)[2]}) + end },{ groups = {dig_immediate = 2, not_in_creative_inventory = 1}, mesecons = { receptor = { - state = mesecon.state.on, rules = signalchanger_get_output_rules, }, effector = { diff --git a/moremesecons_signalchanger/textures/moremesecons_signalchanger_off.png b/moremesecons_signalchanger/textures/moremesecons_signalchanger_off.png index 6996c63bde78571d8d6db0488f8232b3b8c23f56..61303cafab2e323727efd903d2a7c2f2890b6a41 100644 GIT binary patch delta 101 zcmXSz$~eI+p0mIsvY3H^TNs2H8D`CqU|?WiFY)wsWxvlO$gM2pTfQS2D5T`+;uykl zJvkvG!NHBymxoc{3Y!x5FNdZx{1OuU4Wb4N4BuySCEgd)Tme+g;OXk;vd$@?2>`*e B8MXib delta 64 zcmbQrSTMoNO4ZZFF@!@lIl+OI)rW`C;mQ$#3v5c^9?<}vL&xM2dH+u(P!cOH!=N3I)B&)c?QRZ9F@!@l`N#kHjFMmfr$+F*Y~^{a?U+)pc=&%+oBb!A|8E?7{{Lre WPnKj{ThiIW00f?{elF{r5}E+8NE?X&