From fe50e87da17acafb6e869ca94bd4716cc97eb165 Mon Sep 17 00:00:00 2001 From: Novatux Date: Sat, 11 Jan 2014 20:03:37 +0100 Subject: [PATCH] Make receptor_on/off overwritable, fix a serious bug. --- mesecons/actionqueue.lua | 2 +- mesecons/init.lua | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mesecons/actionqueue.lua b/mesecons/actionqueue.lua index 03dedd2..41a587c 100644 --- a/mesecons/actionqueue.lua +++ b/mesecons/actionqueue.lua @@ -38,7 +38,7 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior end if (toremove ~= nil) then - table.remove(mesecon.queue.actions, i) + table.remove(mesecon.queue.actions, toremove) end table.insert(mesecon.queue.actions, action) diff --git a/mesecons/init.lua b/mesecons/init.lua index fe3bbfd..f528dfd 100644 --- a/mesecons/init.lua +++ b/mesecons/init.lua @@ -84,7 +84,7 @@ mesecon.queue:add_function("receptor_on", function (pos, rules) local np = mesecon:addPosRule(pos, rule) -- if area is not loaded, keep trying if minetest.get_node_or_nil(np) == nil then - mesecon.queue:add_action(pos, "receptor_on", {rules}) + mesecon.queue:add_action(pos, "receptor_on", {rules}, nil, rules) return end end @@ -100,7 +100,7 @@ mesecon.queue:add_function("receptor_on", function (pos, rules) end) function mesecon:receptor_on(pos, rules) - mesecon.queue:add_action(pos, "receptor_on", {rules}) + mesecon.queue:add_action(pos, "receptor_on", {rules}, nil, rules) end mesecon.queue:add_function("receptor_off", function (pos, rules) @@ -110,7 +110,7 @@ mesecon.queue:add_function("receptor_off", function (pos, rules) for _, rule in ipairs(mesecon:flattenrules(rules)) do local np = mesecon:addPosRule(pos, rule) if minetest.get_node_or_nil(np) == nil then - mesecon.queue:add_action(pos, "receptor_off", {rules}) + mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules) return end end @@ -122,14 +122,14 @@ mesecon.queue:add_function("receptor_off", function (pos, rules) if not mesecon:connected_to_receptor(np, mesecon:invertRule(rule)) then mesecon:turnoff(np, rulename) else - mesecon:changesignal(np, minetest.get_node(np), rulename, mesecon.state.off, 1) + mesecon:changesignal(np, minetest.get_node(np), rulename, mesecon.state.off, 2) end end end end) function mesecon:receptor_off(pos, rules) - mesecon.queue:add_action(pos, "receptor_off", {rules}) + mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules) end