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

View File

@ -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

View File

@ -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)

View File

@ -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 =
{