From f13ae48730e3725b0efe4442c9d6c570da80c36d Mon Sep 17 00:00:00 2001 From: telkar-rg Date: Sat, 7 Oct 2023 14:28:48 +0200 Subject: [PATCH] changed to show character currencies sorted by their ID --- .../Altoholic/Frames/Currencies.lua | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Altoholic-Addon/Altoholic/Frames/Currencies.lua b/Altoholic-Addon/Altoholic/Frames/Currencies.lua index 9b8219e..3d94c38 100644 --- a/Altoholic-Addon/Altoholic/Frames/Currencies.lua +++ b/Altoholic-Addon/Altoholic/Frames/Currencies.lua @@ -46,8 +46,10 @@ local function GetUsedTokens(header) local realm, account = addon:GetCurrentRealm() local DS = DataStore - local tokens = {} + -- local tokens = {} local useData -- use data for a specific header or not + + local tokensIDname = {} for _, character in pairs(DS:GetCharacters(realm, account)) do -- all alts on this realm local num = DS:GetNumCurrencies(character) or 0 @@ -61,14 +63,28 @@ local function GetUsedTokens(header) end else if useData then -- mark it as used - tokens[name] = true + -- tokens[name] = true tokenTextures[name] = GetItemIcon(itemID) + -- print("-- CURRENCIES:", name, itemID) + tokensIDname[itemID] = name end end end end - return HashToSortedArray(tokens) + local tokensID = {} -- sort by ID + for k,_ in pairs(tokensIDname) do + table.insert(tokensID, k) + end + table.sort(tokensID) + + local returnTable = {} -- insert sorted names + for _,v in pairs(tokensID) do + table.insert(returnTable, tokensIDname[v]) + end + return returnTable + + -- return HashToSortedArray(tokens) end local function DDM_Add(text, func, arg1, arg2)