Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-30-19, 07:54 PM   #1
fail2reap
A Murloc Raider
Join Date: Nov 2019
Posts: 3
GetCurrencyInfo returns 0 CurrentAmount

The following code attempts to store the characters name and current count of Prismatic Manapearls into table a once it recognizes that the add-on has been loaded.

The issue I am having is that when iterating through the table, or even just after getting the value, it always returns CurrentAmount as 0. As a test I also iterated through all currencies and their CurrentAmount values, and surprising they were all 0.

Is the CurrencyAmount loaded at a later time?

Code:
local frame = CreateFrame("FRAME"); 
frame:RegisterEvent("ADDON_LOADED"); 
frame:RegisterEvent("PLAYER_LOGOUT");

function frame:OnEvent(event, arg1)    
    if event == "ADDON_LOADED" and arg1 == "MyPearls" then
        if PearlCount == nil then
            a = {};
        else
            a = PearlCount;
        end

        CurrentAmount = select(2, GetCurrencyInfo(1721));
        a[GetUnitName("player", false)] = CurrentAmount;
        print(CurrentAmount); -- to test its contents

    elseif event == "PLAYER_LOGOUT" then
        PearlCount = a; 
    end
end

frame:SetScript("OnEvent", frame.OnEvent);
SLASH_HOWMANYPEARLS1 = "/pearls";

SlashCmdList["HOWMANYPEARLS"] = function()
    for name, pCount in pairs(a) do
        print(name, " -- ", pCount)
    end
end
Thanks for any info you can provide.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » GetCurrencyInfo returns 0 CurrentAmount

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off