mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-12 19:10:26 +01:00
blinky plant stop if not player in 40 nodes dist(stop useless activations when server is empty)
This commit is contained in:
parent
46407b0062
commit
f24e7560c6
@ -10,11 +10,23 @@ local toggle_timer = function (pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local on_timer = function (pos)
|
local on_timer = function (pos)
|
||||||
local node = minetest.get_node(pos)
|
local activate = false
|
||||||
if(mesecon.flipstate(pos, node) == "on") then
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
mesecon.receptor_on(pos)
|
local p = player:getpos()
|
||||||
else
|
local dist = ((p.x-pos.x)^2 + (p.y-pos.y)^2 + (p.z-pos.z)^2)^0.5
|
||||||
mesecon.receptor_off(pos)
|
if dist < 40 then
|
||||||
|
activate = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if activate then
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
if(mesecon.flipstate(pos, node) == "on") then
|
||||||
|
mesecon.receptor_on(pos)
|
||||||
|
else
|
||||||
|
mesecon.receptor_off(pos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
toggle_timer(pos)
|
toggle_timer(pos)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user