users.lua 738 B

1234567891011121314151617181920
  1. -- ===================================================================
  2. --- Overwrites function at /users.lua.
  3. -- if nil, lists instance members; if an org name, lists its members
  4. -- @function modpol.list_users
  5. -- @param org
  6. -- @return a table with names of players currently in the game
  7. modpol.list_users = function(org)
  8. local users = {}
  9. if (org == nil) then -- no specified org; all players
  10. for _,player in ipairs(minetest.get_connected_players()) do
  11. local name = player:get_player_name()
  12. table.insert(users,name)
  13. end
  14. else -- if an org is specified
  15. if (modpol.orgs[org] ~= nil) then -- org exists
  16. users = modpol.orgs[org]["members"]
  17. end
  18. end
  19. return users
  20. end