don't get all objects in radius

This commit is contained in:
chmodsayshello 2023-04-19 16:27:35 +02:00 committed by ancientmarinerdev
parent 1a1473e8c0
commit a8c989edd8
1 changed files with 6 additions and 7 deletions

View File

@ -213,16 +213,15 @@ local function abm_func(pos)
local power_level = beacon_blockcheck(pos) local power_level = beacon_blockcheck(pos)
local effect_string = meta:get_string("effect") local effect_string = meta:get_string("effect")
if meta:get_int("effect_level") == 2 and power_level < 4 then --no need to run loops when beacon is in an invalid setup :Pi if meta:get_int("effect_level") == 2 and power_level < 4 then --no need to run loops when beacon is in an invalid setup :P
return return
end end
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, (power_level+1)*10)) do for _, obj in pairs(minetest.get_connected_players()) do
if obj:is_player() then if vector.distance(pos,obj:get_pos()) > (power_level+1)*10 then return end --I used Pythagoras at first, and ignored this method lol
if not is_obstructed(pos) then if not is_obstructed(pos) then
effect_player(effect_string,pos,power_level,meta:get_int("effect_level"),obj) effect_player(effect_string,pos,power_level,meta:get_int("effect_level"),obj)
end end
end
end end
end end