mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-12-26 18:30:19 +01:00
Minimal speedup by not checking some nodes twice for receptors
This commit is contained in:
parent
c8c2fd32da
commit
c20a4b3a89
@ -151,13 +151,16 @@ function mesecon:receptor_off(pos, rules)
|
|||||||
rules = mesecon:get_rules("default")
|
rules = mesecon:get_rules("default")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local checked = {}
|
||||||
|
local connected = false
|
||||||
local i = 1
|
local i = 1
|
||||||
while rules[i]~=nil do
|
while rules[i]~=nil do
|
||||||
local np = {}
|
local np = {}
|
||||||
np.x = pos.x + rules[i].x
|
np.x = pos.x + rules[i].x
|
||||||
np.y = pos.y + rules[i].y
|
np.y = pos.y + rules[i].y
|
||||||
np.z = pos.z + rules[i].z
|
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)
|
mesecon:turnoff(np)
|
||||||
end
|
end
|
||||||
i=i+1
|
i=i+1
|
||||||
|
Loading…
Reference in New Issue
Block a user