summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeija <norrepli@gmail.com>2014-01-11 11:19:52 -0800
committerJeija <norrepli@gmail.com>2014-01-11 11:19:52 -0800
commit6c979a6ebb3d7e791c1aa0668b774ff9c3ceb8f6 (patch)
tree874a00618797a69a5e5f05b435c8940c3972c1f8
parent1a492feb7a137a7acfe8cc4d5849970556478e40 (diff)
parentfe50e87da17acafb6e869ca94bd4716cc97eb165 (diff)
downloadmesecons-6c979a6ebb3d7e791c1aa0668b774ff9c3ceb8f6.tar
mesecons-6c979a6ebb3d7e791c1aa0668b774ff9c3ceb8f6.tar.gz
mesecons-6c979a6ebb3d7e791c1aa0668b774ff9c3ceb8f6.tar.bz2
mesecons-6c979a6ebb3d7e791c1aa0668b774ff9c3ceb8f6.tar.xz
mesecons-6c979a6ebb3d7e791c1aa0668b774ff9c3ceb8f6.zip
Merge pull request #142 from Novatux/actionqueue
Action Queue bugfixes by Novatux
-rw-r--r--mesecons/actionqueue.lua3
-rw-r--r--mesecons/init.lua12
2 files changed, 8 insertions, 7 deletions
diff --git a/mesecons/actionqueue.lua b/mesecons/actionqueue.lua
index 66e9fd7..41a587c 100644
--- a/mesecons/actionqueue.lua
+++ b/mesecons/actionqueue.lua
@@ -12,7 +12,6 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior
-- Create Action Table:
time = time or 0 -- time <= 0 --> execute, time > 0 --> wait time until execution
priority = priority or 1
- overwritecheck = overwritecheck or {}
action = { pos=mesecon:tablecopy(pos),
func=func,
params=mesecon:tablecopy(params),
@@ -39,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 523263d..f528dfd 100644
--- a/mesecons/init.lua
+++ b/mesecons/init.lua
@@ -82,8 +82,9 @@ mesecon.queue:add_function("receptor_on", function (pos, rules)
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
for _, rule in ipairs(mesecon:flattenrules(rules)) do
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
@@ -99,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)
@@ -109,7 +110,8 @@ 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
@@ -120,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