BadgeService3 v2 was updated to 3.0.0
Updating is recommended.
There were some updates on which no one was particularly notified of, there were no releases as they were minor updates.
This reply will show significant changes in the module, other things are simple code changes which improve things, but don’t change behaviour.
The updates that I will mention below are changes which can break your current installation of BadgeService3, which might require you to re-write certain parts of your scripts.
If you specifically messed with .Data
then, please read below.
This update is a complete re-write, and with it, there are some behaviour changes, these can break your scripts if you messed with .Data
specifically.
Should I worry?
If you did one of these, you should look into re-writing some code if needed.
- If you used
.Data
to check for if someone owns a badge or anything.
- If you awarded badges through
.Data
;
- If you mutated
.Data
at all;
- If you saved
.Data
together with a bunch of other data. In the sense of literally mixing everything, if you had a ‘partition’ like PlayerData.Badges
, you’re safe from this.
What changed with .Data
?
.Data
is NOT a dictionary anymore. Before it was a dictionary with this base in mind:
{
[badgeId] = true;
}
Now it’s an array, like this:
{
badgeId1,
badgeId2
}
Why was this changed?
I should not have done it with a dictionary anyways, I did it with dictionaries instead for the first time because that would mean that there’s no duplicates, which isn’t an issue unless you handled it poorly.
One thing this helps with, is converting from older data from the v1, since it follows the same format.
Data in datastores are saved in a JSON string, and using arrays is WAY less costly,
It can save up to about 6 characters for each badge owned!
Example:
Old - Dictionary
["WelcomeBadge": true, "10Kills": true, "20Kills": true]
New - Array
["WelcomeBadge", "10Kills", "20Kills"]
Does past data get automatically converted?
The answer to that is yes! BadgeService3 will automatically convert the data if needed.
Data can only get converted when you call any of these functions:
:AwardBadge
:RemoveBadge
:OwnsBadge
:GetOwnedBadges
This conversion is only done once, and only if needed.
The table reference to .Data
is changed to the converted data, and .OnUpdate
is fired.
I haven’t done any of that, what do I need / should change?
Not much, most of the changes are actually syntax changes.
With that said, events are now PastalCase. You can still use camelCase, but the right way now is .OnUpdate
, and not .onUpdate
.
Here’s the most noted changes:
-
.Data
is now an array.
-
:WaitForProfile
doesn’t use Heartbeat anymore, instead it will check whenever a new badge profile is loaded, and check if it’s the player you’re checking.
-
:GetOwnedBadges
is now faster.
There really aren’t many, it’s mostly a optimization and code organization update, but it helps the future of the module.