mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-25 18:20:36 +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,12 +10,24 @@ local toggle_timer = function (pos)
|
||||
end
|
||||
|
||||
local on_timer = function (pos)
|
||||
local activate = false
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local p = player:getpos()
|
||||
local dist = ((p.x-pos.x)^2 + (p.y-pos.y)^2 + (p.z-pos.z)^2)^0.5
|
||||
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
|
||||
toggle_timer(pos)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user