fix(ui): broken getTotalCount function

This commit is contained in:
Guillaume ARM 2024-05-23 20:14:47 +02:00
parent be9e57ebd7
commit e451631810
2 changed files with 7 additions and 5 deletions

View File

@ -5,9 +5,9 @@ local config = {
}
local countersMap = {
iron = 1,
yolo = 2,
truc = 3
{ name = "iron", count = 1 },
{ name = "dye", count = 2 },
{ name = "experience", count = 3 }
}
local result = CountersSelector(countersMap, config)

View File

@ -19,8 +19,10 @@ end
local function getTotalCount(countersMap)
local total = 0
for _, counter in pairs(countersMap) do
total = total + (counter or 0)
for _, counterPayload in pairs(countersMap) do
if counterPayload then
total = total + (counterPayload.count or 0)
end
end
return total
end