Skip to content

Commit

Permalink
fix: progress
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Feb 18, 2024
1 parent 372bc53 commit 9811c6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local function migrateAchievementProgress(player)
local oldStorageKey = achievementProgressStorage + id
local progressNumber = player:getStorageValue(oldStorageKey)
if progressNumber > 0 then
local achievScopeName = tostring(foundAchievement.name .. "-progress")
local achievScopeName = tostring(achievement.name .. "-progress")
player:kv():scoped(achievScopeName, progressNumber)
player:setStorageValue(oldStorageKey, -1)
end
Expand Down
6 changes: 4 additions & 2 deletions data/scripts/lib/register_achievements.lua
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,13 @@ function Player.addAchievementProgress(self, achievement, totalProgress)
local achievScopeName = tostring(foundAchievement.name .. "-progress")
local progressNumber = achievScope:get(achievScopeName) or 0
local newProgress = progressNumber + 1
if newProgress > totalProgress then
return
end

if newProgress == totalProgress then
self:addAchievement(foundAchievement.id)
logger.debug("[Player.addAchievementProgress] - Achievement '{}' completed", foundAchievement.name)
achievScope:remove(achievScopeName)
return
end

logger.debug("[Player.addAchievementProgress] - Achievement '{}' progress updated to '{}', total progress '{}'", foundAchievement.name, newProgress, totalProgress)
Expand Down

0 comments on commit 9811c6e

Please sign in to comment.