forked from mtcontrib/awards
Fix progress exceeding target
This commit is contained in:
parent
805720b4af
commit
38b7d9aa91
@ -44,7 +44,7 @@ function awards.register_trigger(tname, tdef)
|
|||||||
tdef.register(tmp)
|
tdef.register(tmp)
|
||||||
|
|
||||||
function def.getProgress(_, data)
|
function def.getProgress(_, data)
|
||||||
local done = data[tname] or 0
|
local done = math.min(data[tname] or 0, tmp.target)
|
||||||
return {
|
return {
|
||||||
perc = done / tmp.target,
|
perc = done / tmp.target,
|
||||||
label = S(tdef.progress, done, tmp.target),
|
label = S(tdef.progress, done, tmp.target),
|
||||||
@ -103,13 +103,16 @@ function awards.register_trigger(tname, tdef)
|
|||||||
|
|
||||||
-- Called to get progress values and labels
|
-- Called to get progress values and labels
|
||||||
function def.getProgress(_, data)
|
function def.getProgress(_, data)
|
||||||
local done
|
|
||||||
data[tname] = data[tname] or {}
|
data[tname] = data[tname] or {}
|
||||||
|
|
||||||
|
local done
|
||||||
if tmp.key then
|
if tmp.key then
|
||||||
done = data[tname][tmp.key] or 0
|
done = data[tname][tmp.key] or 0
|
||||||
else
|
else
|
||||||
done = data[tname].__total or 0
|
done = data[tname].__total or 0
|
||||||
end
|
end
|
||||||
|
done = math.min(done, tmp.target)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
perc = done / tmp.target,
|
perc = done / tmp.target,
|
||||||
label = S(tdef.progress, done, tmp.target),
|
label = S(tdef.progress, done, tmp.target),
|
||||||
|
Loading…
Reference in New Issue
Block a user