From ef087f2bb63125e041e9ca24d77eb1b987a1b5cc Mon Sep 17 00:00:00 2001 From: Jeija Date: Sat, 19 Jan 2013 22:18:28 +0100 Subject: [PATCH] Fix Bug: Wrong usage of action_on/action_off instead of action_change --- mesecons/init.lua | 2 +- mesecons/internal.lua | 10 +++++----- mesecons_luacontroller/init.lua | 11 ++++------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/mesecons/init.lua b/mesecons/init.lua index 50ed4ca..7f6fe5d 100644 --- a/mesecons/init.lua +++ b/mesecons/init.lua @@ -98,7 +98,7 @@ function mesecon:receptor_off(pos, rules) if not mesecon:connected_to_receptor(np) then mesecon:turnoff(np, rulename) else - mesecon:changesignal(np, minetest.env:get_node(np), rulename) + mesecon:changesignal(np, minetest.env:get_node(np), rulename, mesecon.state.off) end end end diff --git a/mesecons/internal.lua b/mesecons/internal.lua index 2d84787..5e243cf 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -24,7 +24,7 @@ -- SIGNALS -- mesecon:activate(pos, node) --> Activates the effector node at the specific pos (calls nodedef.mesecons.effector.action_on) -- mesecon:deactivate(pos, node) --> Deactivates the effector node at the specific pos (calls nodedef.mesecons.effector.action_off) --- mesecon:changesignal(pos, node) --> Changes the effector node at the specific pos (calls nodedef.mesecons.effector.action_change) +-- mesecon:changesignal(pos, node, rulename, newstate) --> Changes the effector node at the specific pos (calls nodedef.mesecons.effector.action_change) -- RULES -- mesecon:add_rules(name, rules) | deprecated? --> Saves rules table by name @@ -193,10 +193,10 @@ function mesecon:deactivate(pos, node, rulename) end end -function mesecon:changesignal(pos, node, rulename) +function mesecon:changesignal(pos, node, rulename, newstate) local effector = mesecon:get_effector(node.name) if effector and effector.action_change then - effector.action_change (pos, node, rulename) + effector.action_change (pos, node, rulename, newstate) end end @@ -299,7 +299,7 @@ function mesecon:turnon(pos, rulename) end end elseif mesecon:is_effector(node.name) then - mesecon:changesignal(pos, node, rulename) + mesecon:changesignal(pos, node, rulename, mesecon.state.on) if mesecon:is_effector_off(node.name) then mesecon:activate(pos, node, rulename) end @@ -322,7 +322,7 @@ function mesecon:turnoff(pos, rulename) end end elseif mesecon:is_effector(node.name) then - mesecon:changesignal(pos, node, rulename) + mesecon:changesignal(pos, node, rulename, mesecon.state.off) if mesecon:is_effector_on(node.name) and not mesecon:is_powered(pos) then mesecon:deactivate(pos, node, rulename) diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua index 2a633a6..44c38ff 100644 --- a/mesecons_luacontroller/init.lua +++ b/mesecons_luacontroller/init.lua @@ -170,7 +170,7 @@ end local getdigiline_send = function (pos) local digiline_send = function (channel, msg) if digiline then - digiline:receptor_send(pos, digiline.rules.default, channel, minetest.serialize(msg)) + digiline:receptor_send(pos, digiline.rules.default, channel, msg) end end return digiline_send @@ -325,7 +325,7 @@ local digiline = { receptor = {}, effector = { action = function (pos, node, channel, msg) - lc_update (pos, {type = "digiline", iid = {channel = channel, msg = minetest.deserialize(msg)}}) + lc_update (pos, {type = "digiline", iid = {channel = channel, msg = msg}}) end } } @@ -372,12 +372,9 @@ local mesecons = { effector = { rules = input_rules[cid], - action_on = function (pos, _, rulename) - lc_update(pos, {type="on", pin=rulename}) + action_change = function (pos, _, rulename, newstate) + lc_update(pos, {type=newstate, pin=rulename}) end, - action_off = function (pos, _, rulename) - lc_update(pos, {type="off", pin=rulename}) - end }, receptor = {