summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2018-09-14 10:55:55 +0100
committerrubenwardy <rw@rubenwardy.com>2018-09-14 10:55:55 +0100
commit38b7d9aa918c908c485d924b39832a5008bfac0c (patch)
tree4064da43e9b677d3848748bc9710fe9738b5b3aa
parent805720b4af80d55edb8a87a1f8672d09ae2930ad (diff)
Fix progress exceeding target
-rw-r--r--src/api_triggers.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/api_triggers.lua b/src/api_triggers.lua
index 9311bcf..454c79e 100644
--- a/src/api_triggers.lua
+++ b/src/api_triggers.lua
@@ -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),
@@ -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),