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:
Christopher Head
2016-08-20 21:54:15 -07:00
parent 6d79272ed4
commit bc9d4c2d5a
2 changed files with 10 additions and 4 deletions

View File

@ -70,6 +70,8 @@ dofile(minetest.get_modpath("mesecons").."/internal.lua");
-- these are the only functions you need to remember
mesecon.queue:add_function("receptor_on", function (pos, rules)
mesecon.vm_begin()
rules = rules or mesecon.rules.default
-- 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)
end
end
mesecon.vm_commit()
end)
function mesecon.receptor_on(pos, rules)
@ -97,6 +101,8 @@ function mesecon.receptor_on(pos, rules)
end
mesecon.queue:add_function("receptor_off", function (pos, rules)
mesecon.vm_begin()
rules = rules or mesecon.rules.default
-- 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
mesecon.vm_commit()
end)
function mesecon.receptor_off(pos, rules)