# HG changeset patch # User MMOSimca # Date 1476368913 14400 # Node ID f64b4ed77b778aceeaa3296ff4a198d688072ed2 # Parent 26ee8074e5badba28424c5035aa264075793c96b Fixed currency ID support to properly handle nil currency names or currency textures when doing a lookup. diff -r 26ee8074e5ba -r f64b4ed77b77 Main.lua --- a/Main.lua Thu Oct 13 10:22:57 2016 -0400 +++ b/Main.lua Thu Oct 13 10:28:33 2016 -0400 @@ -326,6 +326,7 @@ function CurrencyInfoToID(name, texture) + if not name or not texture then return nil end return currency_info_lookup[("%s:%s"):format(name, texture)] end @@ -1044,7 +1045,9 @@ for i = 1, entry["rewards"]["currency_count"] do local name, texture_path, quantity = _G.GetQuestLogRewardCurrencyInfo(i, quest_id) local currency_id = CurrencyInfoToID(name, texture_path) - table.insert(entry["rewards"]["currencies"], ("%d:%d"):format(quantity, currency_id)) + if currency_id and currency_id ~= 0 then + table.insert(entry["rewards"]["currencies"], ("%d:%d"):format(quantity, currency_id)) + end end end @@ -2553,11 +2556,13 @@ local texture_path, amount_required, item_link, name = _G.GetMerchantItemCostItem(item_index, cost_index) -- Try to detect if this is actually a currency by looking for a nil item_link or item ID - local is_item = item_link and ItemLinkToID(item_link) - - if not is_item then + local is_currency = (not item_link) or (not ItemLinkToID(item_link)) + + if is_currency then local currency_id = CurrencyInfoToID(name, texture_path) - currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, currency_id) + if currency_id and currency_id ~= 0 then + currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, currency_id) + end end end