From 9ced0f6d5c216489131edef3d0564de2281a021f Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Mon, 16 Aug 2021 20:04:45 +0200 Subject: [PATCH] Add modlib.minetest.connected_players --- minetest.lua | 1 + minetest/misc.lua | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/minetest.lua b/minetest.lua index 3837afd..7c78480 100644 --- a/minetest.lua +++ b/minetest.lua @@ -25,6 +25,7 @@ for filename, comps in pairs{ "objects_inside_area", "nodename_matcher", "playerdata", + "connected_players" }, liquid = { "liquid_level_max", diff --git a/minetest/misc.lua b/minetest/misc.lua index 1cc0ec7..be6eb92 100644 --- a/minetest/misc.lua +++ b/minetest/misc.lua @@ -237,3 +237,17 @@ do return data 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