Fix Bug: Wrong usage of action_on/action_off instead of action_change

This commit is contained in:
Jeija 2013-01-19 22:18:28 +01:00
parent 62ddebaecb
commit ef087f2bb6
3 changed files with 10 additions and 13 deletions

@ -98,7 +98,7 @@ function mesecon:receptor_off(pos, rules)
if not mesecon:connected_to_receptor(np) then if not mesecon:connected_to_receptor(np) then
mesecon:turnoff(np, rulename) mesecon:turnoff(np, rulename)
else 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 end
end end

@ -24,7 +24,7 @@
-- SIGNALS -- SIGNALS
-- mesecon:activate(pos, node) --> Activates the effector node at the specific pos (calls nodedef.mesecons.effector.action_on) -- 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: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 -- RULES
-- mesecon:add_rules(name, rules) | deprecated? --> Saves rules table by name -- mesecon:add_rules(name, rules) | deprecated? --> Saves rules table by name
@ -193,10 +193,10 @@ function mesecon:deactivate(pos, node, rulename)
end end
end end
function mesecon:changesignal(pos, node, rulename) function mesecon:changesignal(pos, node, rulename, newstate)
local effector = mesecon:get_effector(node.name) local effector = mesecon:get_effector(node.name)
if effector and effector.action_change then if effector and effector.action_change then
effector.action_change (pos, node, rulename) effector.action_change (pos, node, rulename, newstate)
end end
end end
@ -299,7 +299,7 @@ function mesecon:turnon(pos, rulename)
end end
end end
elseif mesecon:is_effector(node.name) then 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 if mesecon:is_effector_off(node.name) then
mesecon:activate(pos, node, rulename) mesecon:activate(pos, node, rulename)
end end
@ -322,7 +322,7 @@ function mesecon:turnoff(pos, rulename)
end end
end end
elseif mesecon:is_effector(node.name) then 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) if mesecon:is_effector_on(node.name)
and not mesecon:is_powered(pos) then and not mesecon:is_powered(pos) then
mesecon:deactivate(pos, node, rulename) mesecon:deactivate(pos, node, rulename)

@ -170,7 +170,7 @@ end
local getdigiline_send = function (pos) local getdigiline_send = function (pos)
local digiline_send = function (channel, msg) local digiline_send = function (channel, msg)
if digiline then 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
end end
return digiline_send return digiline_send
@ -325,7 +325,7 @@ local digiline = {
receptor = {}, receptor = {},
effector = { effector = {
action = function (pos, node, channel, msg) 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 end
} }
} }
@ -372,12 +372,9 @@ local mesecons = {
effector = effector =
{ {
rules = input_rules[cid], rules = input_rules[cid],
action_on = function (pos, _, rulename) action_change = function (pos, _, rulename, newstate)
lc_update(pos, {type="on", pin=rulename}) lc_update(pos, {type=newstate, pin=rulename})
end, end,
action_off = function (pos, _, rulename)
lc_update(pos, {type="off", pin=rulename})
end
}, },
receptor = receptor =
{ {