Issue with using 'incr' incremental leaderboards in a lua module

I have an issue with using ‘incr’ leaderboards in a lua module. (Nakama 2.6.0)

I was using the leaderboard with the best parameter, and the leaderboard settings didn’t update the setting when I changed the leaderboard initialization code.

I update the leaderboard but only the best value is recorded for the user. It seems it’s still acting as if it’s a best leaderboard.

Do I have to manually delete the leaderboard from the server to make it update the settings?

I was able to fix it by changing the leaderboard name I’m using from “totalCoins” and “totalRewards”, but it would be great if the leaderboard settings could be changed when needed (even if means deleting all the leaderboard data).

More details:

Not only for the match or even for the session, the value is just never incremented unless there is a new “best” value given that’s higher than the recorded one.

The leaderboard set call does not return an error and the log file shows no errors.

Here is the whole method I’m using
here: https://pastebin.com/LSRHEunc

For clarification, when I added a logger call under if changeset.coins >0 then it was printing that it’s updating the leaderboard when it should
i.e. when skip_leaderboard is false and when coins are positive.

But when i check the leaderboard afterwards it always only shows the first/best value set.
The leaderboard is defined with
nk.leaderboard_create(plat .. "-" .. "totalCoins", authoritative, sort, "incr", reset, metadata)

Should I open a github issue?

This is not a bug, leaderboard settings cannot be updated after the leaderboard is created. Too much logic and behaviour depends on the settings to be changed on the fly.

Leaderboard creation is short-circuited if the leaderboard ID you’re trying to create already exists to allow repeat creation of a known set of leaderboards in server startup phases.

If you want to change the operator of a leaderboard you should delete and create it again, but this should not be a common operation in production - I expect this is something you’ll only want to do for development?

You’re right I can’t imagine needing to do that very often, I just didn’t see an error when trying to overwrite the leaderboard and imagined there was something wrong with it.

We could possibly have this in the leaderboard docs somewhere to mitigate this.

We do mention this but it’s not specifically highlighted.

All leaderboard configuration is immutable once created. You should delete the leaderboard and create a new one if you need to change the sort order or operator.

1 Like