Currency Name to Currency ID
According to wow.gamepedia.com/API_GetMerchantItemCostItem the 3rd and 4th return values are:
itemLink String - An itemLink for the cost item, nil if a currency. currencyName String - Name of the currency required, nil if an item. I want to know how much of the currency the player has, but all the currency API functions seem to want an index or an ID, not the localized name of the currency. Am I missing something? Do I have to enumerate all the currencies until I find a localized name match to get the index or ID? |
From looking at how other currency tracking addons get the data, they loop through GetCurrencyListInfo() for GetCurrencyListSize() times to pull all of the currency info the player currently has into a table or a db, and then they manipulate the data into their output frames.
|
Looks like you can just call GetMerchantItemCostItem for the item link and then call GetItemCount(itemLink, false, false, true) for your count.
This is what the interface does to check if you can afford something. |
Quote:
Unfortunately, I think briskman3000 has the solution (I didn't want to go there). |
Since the UI lists out your currencies on the vendor frame, you can look at how it does that to get your currency counts.
It calls GetMerchantCurrencies() to get what currencies you can spend at the current vendor, and GetCurrencyInfo() to get the name and count for them. You should only need to loop over your entire list of currencies if the vendor doesn't tell you what currencies you can spend at it. |
For Skillet, I'm looking at further refinement of the "how many can I craft" counts. When I fixed the calculations because someone reported they were too low, I discovered that some counts were now too high because, for example, you could trade Blood of Sargaras for almost all of the Legion crafting materials, and Garrison Resources for most of the WoD crafting materials.
I now (optionally) ignore materials obtained that way, but if you change the option to consider them, it would be better to see how many you could buy with the currency you have as opposed to just using infinity. Since I need to use the count at the time I do the calculations, GetCurrencyInfo(id) will work the best but finding the value for id isn't exactly obvious. I believe I've got it now. |
All times are GMT -6. The time now is 10:33 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI