Its not pretty by any means, i ran into 2 problems.
1 having to removing text string formating. In doing so i created another problem i over looked for a short time. Some times the text strings only have one digit EG. 2 gold 2 silver 2 copper.
i removed the formating and got
222 when reading format i got 2 silver 22 copper lol.
so as you commented earlier, is why i did the way i did. i had to first cache string, filter for each denomination. do alil math to get
20202 or 2 gold 2 silver 2 copper. I know there has to be a more effictient way to do this, i just didnt see it
Code:
function GTpars*********()
if (gameArrayGold == nil) then
gameArrayGold = {};
end
-- NOTICE This function is copyright 2010 - 2017 Shawn E. Carter, [email protected]
-- GETS ALL MONEY AND REMOVES FORMATING.
-- 95511|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t
-- 5|TInterface\\MoneyFrame\\UI-SilverIcon:0:0:2:0|t
-- 12|TInterface\\MoneyFrame\\UI-CopperIcon:0:0:2:0|t
-- 95511|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t 5|TInterface\\MoneyFrame\\UI-SilverIcon:0:0:2:0|t 12|TInterface\\MoneyFrame\\UI-CopperIcon:0:0:2:0|t
-- =========================================
local TOTAL_GOLD_ACQUIRED = "328"
local txt = GetStatistic(TOTAL_GOLD_ACQUIRED);
-- =========================================
local iscopper = txt:match("%d+|TInterface\\MoneyFrame\\UI%-CopperIcon:0:0:2:0|t");
if (iscopper == nil or iscopper == "") then
iscopper = "0";
end
local issilver = txt:match("%d+|TInterface\\MoneyFrame\\UI%-SilverIcon:0:0:2:0|t");
if (issilver == nil or issilver == "") then
issilver = "0";
end
local isgold = txt:match("%d+|TInterface\\MoneyFrame\\UI%-GoldIcon:0:0:2:0|t");
if (isgold == nil or isgold == "") then
isgold = "0";
end
local iscopper1 = iscopper:match("%d+");
if (iscopper1 == nil or iscopper1 == "") then
iscopper1 = "0";
end
local issilver1 = issilver:match("%d+");
if (issilver1 == nil or issilver1 == "") then
issilver1 = "0";
end
local isgold1 = isgold:match("%d+");
if (isgold1 == nil or isgold1 == "") then
isgold1 = "0";
end
local DEmoneyLife = iscopper1 + (issilver1*100) + (isgold1*10000);
local charmoney = "Assets"
local charlifemoney = "Money"
local charspent = "Spent"
local charlifegold = "Gold"
local charlifesilver = "Silver"
local charlifecopper = "Copper"
local charlifegold1 = "Gold1"
local charlifesilver1 = "Silver1"
local charlifecopper1 = "Copper1"
-- local GTspent = 0 - GetMoney("player");
-- =========================================
--local realm, char, = GetRealmName(), UnitName'player';
local realm = GetCVar("realmName");
local curchar = UnitName("player");
local faction = UnitFactionGroup("Player");
local stackGT = GetCVar("realmName").."::"..UnitFactionGroup("Player").."\\"..UnitName("player");
-- =========================================
if (gameArrayGold[stackGT] == nil) then
gameArrayGold[stackGT] = GetMoney("player");
end
if (GTgameArray == nil) then
GTgameArray = {};
end
if (GTgameArray[realm] == nil) then
GTgameArray[realm] = {};
end
if (GTgameArray[realm][faction] == nil) then
GTgameArray[realm][faction] = {};
end
if (GTgameArray[realm][faction][curchar] == nil) then
GTgameArray[realm][faction][curchar] = {};
end
if (GTgameArray[realm][faction][curchar][charmoney] == nil) then
GTgameArray[realm][faction][curchar][charmoney] = GetMoney("player").."";
else
GTgameArray[realm][faction][curchar][charmoney] = GetMoney("player").."";
end
-- if (GTgameArray["ALLassets"] == nil) then
-- GTgameArray["ALLassets"] = 0
-- end
-- ========================================= copper copper1
if (GTgameArray[realm][faction][curchar][charlifecopper] == nil) then
GTgameArray[realm][faction][curchar][charlifecopper] = iscopper.."";
else
GTgameArray[realm][faction][curchar][charlifecopper] = iscopper.."";
end
if (GTgameArray[realm][faction][curchar][charlifecopper1] == nil) then
GTgameArray[realm][faction][curchar][charlifecopper1] = iscopper1.."";
else
GTgameArray[realm][faction][curchar][charlifecopper1] = iscopper1.."";
end
-- =========================================
if (GTgameArray[realm][faction][curchar][charlifesilver] == nil) then
GTgameArray[realm][faction][curchar][charlifesilver] = issilver.."";
else
GTgameArray[realm][faction][curchar][charlifesilver] = issilver.."";
end
if (GTgameArray[realm][faction][curchar][charlifesilver1] == nil) then
GTgameArray[realm][faction][curchar][charlifesilver1] = issilver1.."";
else
GTgameArray[realm][faction][curchar][charlifesilver1] = issilver1.."";
end
-- =========================================
if (GTgameArray[realm][faction][curchar][charlifegold] == nil) then
GTgameArray[realm][faction][curchar][charlifegold] = isgold.."";
else
GTgameArray[realm][faction][curchar][charlifegold] = isgold.."";
end
if (GTgameArray[realm][faction][curchar][charlifegold1] == nil) then
GTgameArray[realm][faction][curchar][charlifegold1] = isgold1.."";
else
GTgameArray[realm][faction][curchar][charlifegold1] = isgold1.."";
end
-- =========================================
-- if (GTgameArray[realm][faction][curchar][charspent] == nil) then
-- GTgameArray[realm][faction][curchar][charspent] = GTspent.."";
-- else
-- GTgameArray[realm][faction][curchar][charspent] = GTspent.."";
-- end
-- =========================================
if (GTgameArray[realm][faction][curchar][charlifemoney] == nil) then
GTgameArray[realm][faction][curchar][charlifemoney] = DEmoneyLife.."";
else
GTgameArray[realm][faction][curchar][charlifemoney] = DEmoneyLife.."";
end
local total_money = 0
if (total_money == nil) then
total_money = 0
end
local total_Assets = 0
if (total_Assets == nil) then
total_Assets = 0
end
if (GTgameArray["ALLgold"] == nil) then
GTgameArray["ALLgold"] = 0;
end
if (GTgameArray["ALLassets"] == nil) then
GTgameArray["ALLassets"] = 0;
end
for key, realm in pairs(GTgameArray) do
-- Because ALLgold will be at same table level as realm names with your current table layout.
if key ~= "ALLgold" then
for _, faction in pairs(realm) do
for _, character in pairs(faction) do
-- Because you have strings instead of integers, convert to numer here.
total_money = total_money + tonumber(character["Money"]);
GTgameArray["ALLgold"] = total_money;
end
end
end
if key ~= "ALLassets" then
for _, faction in pairs(realm) do
for _, character in pairs(faction) do
-- Because you have strings instead of integers, convert to numer here.
total_Assets = total_Assets + tonumber(character["Assets"]);
GTgameArray["ALLassets"] = total_Assets;
end
end
end
end
convertedGameGold3 = GetCoinTextureString(total_money, " ");
GGAquired:SetText(""..convertedGameGold3.."");
end