mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
Add minetest.get_connected_players()
This commit is contained in:
parent
bbf3eebb1a
commit
80a64341f0
@ -837,6 +837,17 @@ function minetest.check_player_privs(name, privs)
|
|||||||
return true, ""
|
return true, ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function minetest.get_connected_players()
|
||||||
|
-- This could be optimized a bit, but leave that for later
|
||||||
|
local list = {}
|
||||||
|
for _, obj in pairs(minetest.env:get_objects_inside_radius({x=0,y=0,z=0}, 1000000)) do
|
||||||
|
if obj:get_player_name() then
|
||||||
|
table.insert(list, obj)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return list
|
||||||
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Chat commands
|
-- Chat commands
|
||||||
--
|
--
|
||||||
|
@ -8,15 +8,13 @@ experimental = {}
|
|||||||
|
|
||||||
experimental.player_visual_index = 0
|
experimental.player_visual_index = 0
|
||||||
function switch_player_visual()
|
function switch_player_visual()
|
||||||
for _, obj in pairs(minetest.env:get_objects_inside_radius({x=0,y=0,z=0}, 1000000)) do
|
for _, obj in pairs(minetest.get_connected_players()) do
|
||||||
if obj:get_player_name() then
|
|
||||||
if experimental.player_visual_index == 0 then
|
if experimental.player_visual_index == 0 then
|
||||||
obj:set_properties({visual="upright_sprite"})
|
obj:set_properties({visual="upright_sprite"})
|
||||||
else
|
else
|
||||||
obj:set_properties({visual="cube"})
|
obj:set_properties({visual="cube"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
experimental.player_visual_index = (experimental.player_visual_index + 1) % 2
|
experimental.player_visual_index = (experimental.player_visual_index + 1) % 2
|
||||||
minetest.after(1.0, switch_player_visual)
|
minetest.after(1.0, switch_player_visual)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user