forked from Mineclonia/Mineclonia
iterate over players instead of searching for objects
This commit is contained in:
parent
327cf537b5
commit
c76ca816b2
|
@ -192,8 +192,8 @@ minetest.register_entity("mcl_enchanting:book", {
|
||||||
local old_player_near = self._player_near
|
local old_player_near = self._player_near
|
||||||
local player_near = false
|
local player_near = false
|
||||||
local player
|
local player
|
||||||
for _, obj in ipairs(minetest.get_objects_inside_radius(vector.subtract(self.object:get_pos(), mcl_enchanting.book_offset), 2.5)) do
|
for _,obj in pairs(minetest.get_connected_players()) do
|
||||||
if obj:is_player() then
|
if vector.distance(obj:get_pos(),self.object:get_pos()) < 2.5 then
|
||||||
player_near = true
|
player_near = true
|
||||||
player = obj
|
player = obj
|
||||||
end
|
end
|
||||||
|
@ -309,8 +309,8 @@ minetest.register_abm({
|
||||||
nodenames = "mcl_enchanting:table",
|
nodenames = "mcl_enchanting:table",
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
local playernames = {}
|
local playernames = {}
|
||||||
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 15)) do
|
for _,obj in pairs(minetest.get_connected_players()) do
|
||||||
if obj:is_player() then
|
if vector.distance(obj:get_pos(),pos) < 15 then
|
||||||
table.insert(playernames, obj:get_player_name())
|
table.insert(playernames, obj:get_player_name())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue