Add modlib.minetest.connected_players

This commit is contained in:
Lars Mueller 2021-08-16 20:04:45 +02:00
parent 29ffa18ff6
commit 9ced0f6d5c
2 changed files with 15 additions and 0 deletions

@ -25,6 +25,7 @@ for filename, comps in pairs{
"objects_inside_area", "objects_inside_area",
"nodename_matcher", "nodename_matcher",
"playerdata", "playerdata",
"connected_players"
}, },
liquid = { liquid = {
"liquid_level_max", "liquid_level_max",

@ -237,3 +237,17 @@ do
return data return data
end end
end end
function connected_players()
-- TODO cache connected players
local connected_players = minetest.get_connected_players()
local index = 0
local len = #connected_players
return function()
if index >= len then
return
end
index = index + 1
return connected_players[index]
end
end