Playdate.scoreboards helper script

, ,

Hello! This week Panic released documentation for their Scoreboard API available to catalog games and I thought it looked pretty nice. I wanted to be able to use the API even if I didn't have access to the official scoreboards, so I wrote a little script that checks Panic's servers for any and creates a local version if they don't have access. It also skips the server check if it's already tried, failed, and created local scoreboards in the past.

preview

I put it on GitHub: GammaGames/pdScoreboards

Usage is hopefully easy:

import "pdScoreboards"

playdate.scoreboards.initialize({
    { boardID = "highscores", name = "High Scores" },
    { boardID = "lowscores", name = "Low Scores", order="ascending" }
}, function(status, _)
    if status.code == "OK" then
        print("You're using official scoreboards!")
    else
        print("You're not using official scoreboards, but that's okay!")
    end
end)

Thoughts? I think something like this in the official SDK would be nice!

2 Likes

Also: When you're approved to use the catalog API, what is the expected behavior if you try to do anything on first run while disconnected from wifi? I made this do nothing if that happens, as far as I could tell the catalog API only replied with "Wi-Fi not available" so I'd expect it to fail on any following API calls

The playdate.scoreboards.getScoreboards function has started giving an error with "Bad response from server" message, not sure what that's about... Don't have a device but my 2.0.1 sim is registered :person_shrugging:

I updated the script so it'll only show the top 10 + player's score, so it matches the SDK properly. The next step will probably be to add a score manager similar to what Scenic Route shared on the pd squad discord.

It looks like a scoreboard bug was introduce in 2.0.1, so we are looking at getting a fix in for that asap.

(see also: https://devforum.play.date/t/crash-on-2-0-1-windows-simulator/12090_)

1 Like

+1 on that! It would be great if the API were available to everyone, and the only distinction between catalog and non-catalog games is whether the network/cloud portion functioned. That way we could all build games with local high score support, and if accepted to catalog things would Just Work.

In reading the API docs, I didn't see anything that mentions how a game should register a scoreboard. Are you making the assumption that's done in init? Can someone with first-hand experience clarify how that works? Is there a limit to the number of scoreboards a game can register?

Also, one more question for anyone in the know… the docs indicate that getScores() takes a boardID, but that addScore and getPersonalBest take a boardName instead. Is that a typo, or are name strings really being used as the unique identifier in some parts of the API?

1 Like

There’s no way to register scoreboards, panic makes them for you on the server so I’m not sure on any limitation. I set up the init function because it needed some way to know what was available.

Good catch on the docs, now I’m curious as well!

@Gamma Thanks for providing the github. Is there an easy way to use this same code, but repurpose it to make it go to local directly?

I want to be able to display localscores right away and then give the option to pull globalscores if the player wants to.

Like, don’t try the servers at all? You could change the init function so it looked like this (untested)

function playdate.scoreboards.initialize(boards, callback, path) 
    scoreboards_file = path or "scoreboards" 
    scoreboards = playdate.datastore.read(scoreboards_file)
    _init_scoreboards(boards)
    callback(…)
end
1 Like

Thanks Gamma! I think this works.

1 Like