From e451631810cfb9c92a9ac818b8e7f4ba1f4919c1 Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Thu, 23 May 2024 20:14:47 +0200 Subject: [PATCH] fix(ui): broken getTotalCount function --- inferium-gui.lua | 6 +++--- libs/ui/CountersSelector.lua | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/inferium-gui.lua b/inferium-gui.lua index b06d4b5..e460105 100644 --- a/inferium-gui.lua +++ b/inferium-gui.lua @@ -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) diff --git a/libs/ui/CountersSelector.lua b/libs/ui/CountersSelector.lua index ca0d292..37ef2bb 100644 --- a/libs/ui/CountersSelector.lua +++ b/libs/ui/CountersSelector.lua @@ -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