forked from Mirrorlandia_minetest/mesecons
Use VM transactions for conductor state changes.
VoxelManipulator-based transactions are used to hopefully speed up scanning and replacing of networks of conductors when receptors start or stop driving signals into them.
This commit is contained in:
parent
6d79272ed4
commit
bc9d4c2d5a
@ -70,6 +70,8 @@ dofile(minetest.get_modpath("mesecons").."/internal.lua");
|
|||||||
-- these are the only functions you need to remember
|
-- these are the only functions you need to remember
|
||||||
|
|
||||||
mesecon.queue:add_function("receptor_on", function (pos, rules)
|
mesecon.queue:add_function("receptor_on", function (pos, rules)
|
||||||
|
mesecon.vm_begin()
|
||||||
|
|
||||||
rules = rules or mesecon.rules.default
|
rules = rules or mesecon.rules.default
|
||||||
|
|
||||||
-- 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
|
||||||
@ -90,6 +92,8 @@ mesecon.queue:add_function("receptor_on", function (pos, rules)
|
|||||||
mesecon.turnon(np, rulename)
|
mesecon.turnon(np, rulename)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mesecon.vm_commit()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function mesecon.receptor_on(pos, rules)
|
function mesecon.receptor_on(pos, rules)
|
||||||
@ -97,6 +101,8 @@ function mesecon.receptor_on(pos, rules)
|
|||||||
end
|
end
|
||||||
|
|
||||||
mesecon.queue:add_function("receptor_off", function (pos, rules)
|
mesecon.queue:add_function("receptor_off", function (pos, rules)
|
||||||
|
mesecon.vm_begin()
|
||||||
|
|
||||||
rules = rules or mesecon.rules.default
|
rules = rules or mesecon.rules.default
|
||||||
|
|
||||||
-- 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
|
||||||
@ -119,6 +125,8 @@ mesecon.queue:add_function("receptor_off", function (pos, rules)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mesecon.vm_commit()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function mesecon.receptor_off(pos, rules)
|
function mesecon.receptor_off(pos, rules)
|
||||||
|
@ -405,8 +405,7 @@ function mesecon.turnon(pos, link)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if success then
|
if success then
|
||||||
minetest.swap_node(f.pos, {name = mesecon.get_conductor_on(node, f.link),
|
mesecon.swap_node_force(f.pos, mesecon.get_conductor_on(node, f.link))
|
||||||
param2 = node.param2})
|
|
||||||
|
|
||||||
for npos, links in pairs(neighborlinks) do
|
for npos, links in pairs(neighborlinks) do
|
||||||
-- links = all links to node, l = each single link
|
-- links = all links to node, l = each single link
|
||||||
@ -465,8 +464,7 @@ function mesecon.turnoff(pos, link)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if success then
|
if success then
|
||||||
minetest.swap_node(f.pos, {name = mesecon.get_conductor_off(node, f.link),
|
mesecon.swap_node_force(f.pos, mesecon.get_conductor_off(node, f.link))
|
||||||
param2 = node.param2})
|
|
||||||
|
|
||||||
for npos, links in pairs(neighborlinks) do
|
for npos, links in pairs(neighborlinks) do
|
||||||
-- links = all links to node, l = each single link
|
-- links = all links to node, l = each single link
|
||||||
|
Loading…
Reference in New Issue
Block a user