Skip to content

Commit

Permalink
Fix progress exceeding target
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Sep 14, 2018
1 parent 805720b commit 38b7d9a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/api_triggers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function awards.register_trigger(tname, tdef)
tdef.register(tmp)

function def.getProgress(_, data)
local done = data[tname] or 0
local done = math.min(data[tname] or 0, tmp.target)
return {
perc = done / tmp.target,
label = S(tdef.progress, done, tmp.target),
Expand Down Expand Up @@ -103,13 +103,16 @@ function awards.register_trigger(tname, tdef)

-- Called to get progress values and labels
function def.getProgress(_, data)
local done
data[tname] = data[tname] or {}

local done
if tmp.key then
done = data[tname][tmp.key] or 0
else
done = data[tname].__total or 0
end
done = math.min(done, tmp.target)

return {
perc = done / tmp.target,
label = S(tdef.progress, done, tmp.target),
Expand Down

0 comments on commit 38b7d9a

Please sign in to comment.