Iterating through weak_map

Hello,

I was tasked with creating a global leaderboard for an island. I initially thought this would be a straightforward task and broke it down into the following steps:

  1. Create persistent storage (which is well-explained in the tutorial).
  2. Determine the data to store—in my case, Kills and Deaths.
  3. Create an array based on the persistent object and sort it by the player’s number of kills.
  4. Display the top N records from the array on a billboard.

Everything seemed simple until I started working on step #3. I discovered that weak_map cannot be iterated over (yes, I overlooked the tutorial’s note: “A weak_map is a simple map that cannot be iterated over”). This means I can’t create an array containing all records from the weak_map.

However, I was curious about how leaderboards are implemented on other islands. After extensive searching, I came across a Reddit comment stating: “You can’t make a global leaderboard. People submit their scores to Discord, and they get added manually.”

Is this true?
Is it really impossible to use a persistent object for a global leaderboard? If not, what alternatives exist for achieving this functionality?

Thanks in advance!

Yes, unfortunately global leaderboards are not actually “global” at the moment and are only submitted scores from players through social media/discord.

1 Like