diff options
author | Jeija <norrepli@gmail.com> | 2012-08-13 09:37:55 +0200 |
---|---|---|
committer | Jeija <norrepli@gmail.com> | 2012-08-13 09:37:55 +0200 |
commit | c20a4b3a897b2c55ec6dd7b84fb6404c387d16d0 (patch) | |
tree | 118272d5e46bc210ea501097a8b6b6ded3318c2b | |
parent | c8c2fd32daafed87beb820f516749b83dce3e4df (diff) | |
download | mesecons-c20a4b3a897b2c55ec6dd7b84fb6404c387d16d0.tar mesecons-c20a4b3a897b2c55ec6dd7b84fb6404c387d16d0.tar.gz mesecons-c20a4b3a897b2c55ec6dd7b84fb6404c387d16d0.tar.bz2 mesecons-c20a4b3a897b2c55ec6dd7b84fb6404c387d16d0.tar.xz mesecons-c20a4b3a897b2c55ec6dd7b84fb6404c387d16d0.zip |
Minimal speedup by not checking some nodes twice for receptors
-rw-r--r-- | mesecons/init.lua | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/mesecons/init.lua b/mesecons/init.lua index 3697c7a..6715a2f 100644 --- a/mesecons/init.lua +++ b/mesecons/init.lua @@ -151,13 +151,16 @@ function mesecon:receptor_off(pos, rules) rules = mesecon:get_rules("default") end + local checked = {} + local connected = false local i = 1 while rules[i]~=nil do local np = {} np.x = pos.x + rules[i].x np.y = pos.y + rules[i].y np.z = pos.z + rules[i].z - if not mesecon:connected_to_pw_src(np) then + connected, checked = mesecon:connected_to_pw_src(np, checked) + if not connected then mesecon:turnoff(np) end i=i+1 |