diff options
author | Christopher Head <chead@chead.ca> | 2016-08-20 21:54:15 -0700 |
---|---|---|
committer | Christopher Head <chead@chead.ca> | 2016-08-24 00:42:40 -0700 |
commit | bc9d4c2d5a1d535f4abc001d527cc65c78227016 (patch) | |
tree | 1b085f38d9ea227bd9b8ef11abcc1820b2d3280b | |
parent | 6d79272ed4966b63e2035b19af07d13f2a0be2a3 (diff) | |
download | mesecons-bc9d4c2d5a1d535f4abc001d527cc65c78227016.tar mesecons-bc9d4c2d5a1d535f4abc001d527cc65c78227016.tar.gz mesecons-bc9d4c2d5a1d535f4abc001d527cc65c78227016.tar.bz2 mesecons-bc9d4c2d5a1d535f4abc001d527cc65c78227016.tar.xz mesecons-bc9d4c2d5a1d535f4abc001d527cc65c78227016.zip |
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.
-rw-r--r-- | mesecons/init.lua | 8 | ||||
-rw-r--r-- | mesecons/internal.lua | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/mesecons/init.lua b/mesecons/init.lua index 6b36e69..944a86a 100644 --- a/mesecons/init.lua +++ b/mesecons/init.lua @@ -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) diff --git a/mesecons/internal.lua b/mesecons/internal.lua index 4ef2b18..e11de4f 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -405,8 +405,7 @@ function mesecon.turnon(pos, link) end if success then - minetest.swap_node(f.pos, {name = mesecon.get_conductor_on(node, f.link), - param2 = node.param2}) + mesecon.swap_node_force(f.pos, mesecon.get_conductor_on(node, f.link)) for npos, links in pairs(neighborlinks) do -- links = all links to node, l = each single link @@ -465,8 +464,7 @@ function mesecon.turnoff(pos, link) end if success then - minetest.swap_node(f.pos, {name = mesecon.get_conductor_off(node, f.link), - param2 = node.param2}) + mesecon.swap_node_force(f.pos, mesecon.get_conductor_off(node, f.link)) for npos, links in pairs(neighborlinks) do -- links = all links to node, l = each single link |