Back to Home

ESO Lua File v101050

publicallingames/achievements/achievementsutils.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
ZO_ACHIEVEMENTS_COMPLETION_STATUS = 
{
    NOT_APPLICABLE = 1,
    INCOMPLETE = 2,
    IN_PROGRESS = 3,
    COMPLETE = 4,
}
function ZO_GetAchievementStatus(achievementId)
    local completed = 0
    local total = 0
    local numCriteria = GetAchievementNumCriteria(achievementId)
    for criterionIndex = 1, numCriteria do
        local _, numCompleted, numRequired = GetAchievementCriterion(achievementId, criterionIndex)
        completed = completed + numCompleted
        total = total + numRequired
    end
    if total > 0 then
        if completed > 0 then
            if completed == total then
                return ZO_ACHIEVEMENTS_COMPLETION_STATUS.COMPLETE
            else
                return ZO_ACHIEVEMENTS_COMPLETION_STATUS.IN_PROGRESS
            end
        else
            return ZO_ACHIEVEMENTS_COMPLETION_STATUS.INCOMPLETE
        end
    end
    return ZO_ACHIEVEMENTS_COMPLETION_STATUS.NOT_APPLICABLE
end