comparison Main.lua @ 519:2325dbe5c10a

Fixed merchant cost detection for items that cost items (i.e. Tricky Treats, Darkmoon Daggermaw, etc).
author MMOSimca <mmosimca@gmail.com>
date Tue, 08 Nov 2016 19:05:42 -0500
parents 0635db205d44
children 3fee2a08fdaa
comparison
equal deleted inserted replaced
518:0635db205d44 519:2325dbe5c10a
2555 2555
2556 for cost_index = 1, item_count do 2556 for cost_index = 1, item_count do
2557 -- The third return (Blizz calls "currency_link") of GetMerchantItemCostItem only returns item links as of Patch 5.3.0. 2557 -- The third return (Blizz calls "currency_link") of GetMerchantItemCostItem only returns item links as of Patch 5.3.0.
2558 local texture_path, amount_required, item_link, name = _G.GetMerchantItemCostItem(item_index, cost_index) 2558 local texture_path, amount_required, item_link, name = _G.GetMerchantItemCostItem(item_index, cost_index)
2559 2559
2560 -- Try to detect if this is actually a currency by looking for a nil item_link or item ID 2560 -- Try to get item ID
2561 local is_currency = (not item_link) or (not ItemLinkToID(item_link)) 2561 local item_id = ItemLinkToID(item_link)
2562 2562
2563 if is_currency then 2563 -- FUTURE: At some point, we should make the output from these two cases (item_id vs currency_id) slightly different, so that WoWDB doesn't have to guess if it is a currency or item
2564 -- Handle cases when the additional cost is another item
2565 if item_id and item_id > 0 then
2566 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, item_id)
2567 -- Handle cases when the additional cost is another currency
2568 else
2564 local currency_id = CurrencyInfoToID(name, texture_path) 2569 local currency_id = CurrencyInfoToID(name, texture_path)
2565 if currency_id and currency_id ~= 0 then 2570 if currency_id and currency_id > 0 then
2566 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, currency_id) 2571 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, currency_id)
2567 end 2572 end
2568 end 2573 end
2569 end 2574 end
2570 2575