mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-11-05 06:53:44 +01:00
Merge pull request #142 from Novatux/actionqueue
Action Queue bugfixes by Novatux
This commit is contained in:
commit
6c979a6ebb
@ -12,7 +12,6 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior
|
|||||||
-- Create Action Table:
|
-- Create Action Table:
|
||||||
time = time or 0 -- time <= 0 --> execute, time > 0 --> wait time until execution
|
time = time or 0 -- time <= 0 --> execute, time > 0 --> wait time until execution
|
||||||
priority = priority or 1
|
priority = priority or 1
|
||||||
overwritecheck = overwritecheck or {}
|
|
||||||
action = { pos=mesecon:tablecopy(pos),
|
action = { pos=mesecon:tablecopy(pos),
|
||||||
func=func,
|
func=func,
|
||||||
params=mesecon:tablecopy(params),
|
params=mesecon:tablecopy(params),
|
||||||
@ -39,7 +38,7 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior
|
|||||||
end
|
end
|
||||||
|
|
||||||
if (toremove ~= nil) then
|
if (toremove ~= nil) then
|
||||||
table.remove(mesecon.queue.actions, i)
|
table.remove(mesecon.queue.actions, toremove)
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(mesecon.queue.actions, action)
|
table.insert(mesecon.queue.actions, action)
|
||||||
|
@ -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
|
-- 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
|
for _, rule in ipairs(mesecon:flattenrules(rules)) do
|
||||||
local np = mesecon:addPosRule(pos, rule)
|
local np = mesecon:addPosRule(pos, rule)
|
||||||
|
-- if area is not loaded, keep trying
|
||||||
if minetest.get_node_or_nil(np) == nil then
|
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
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -99,7 +100,7 @@ mesecon.queue:add_function("receptor_on", function (pos, rules)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
function mesecon:receptor_on(pos, rules)
|
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
|
end
|
||||||
|
|
||||||
mesecon.queue:add_function("receptor_off", function (pos, rules)
|
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
|
for _, rule in ipairs(mesecon:flattenrules(rules)) do
|
||||||
local np = mesecon:addPosRule(pos, rule)
|
local np = mesecon:addPosRule(pos, rule)
|
||||||
if minetest.get_node_or_nil(np) == nil then
|
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
|
||||||
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
|
if not mesecon:connected_to_receptor(np, mesecon:invertRule(rule)) then
|
||||||
mesecon:turnoff(np, rulename)
|
mesecon:turnoff(np, rulename)
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function mesecon:receptor_off(pos, rules)
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user