I've an addon that currently will look through a merchant's inventory and tell the user how many recipes he has. I'd also like it to list how many recipes he has that are
currently learnable.
I tried using the function
IsUsableItem(itemLink), but that function returns true for any recipe I currently have in my inventory (which, technically, is usable, I suppose). What function should I be using to determine an item's "learnability?" The more information I can get, the better.
Here's my current merchant search:
Lua Code:
function checkMerchantInventory()
local itemCount = GetMerchantNumItems()
local recipeCount = 0
local usableCount = 0
for i=1,itemCount do
-- Our current item.
local currentItem = GetMerchantItemLink(i)
if (currentItem == nil) then
scanSuccessful = false
return
end
-- Get assorted information about the item.
local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(currentItem)
if (class == "Recipe") then
recipeCount = recipeCount + 1
-- Get usability information about the item.
local isUsable = IsUsableItem(currentItem)
if (isUsable) then
usableCount = usableCount + 1
print(currentItem)
end
end
end
-- Search output
if recipeCount > 0 then
print("|cFFFF6666 Look! New Recipe!|r "..recipeCount.." recipes, of which "..usableCount.." are useable.")
PlaySoundFile("Sound/Creature/Cat/CatStepA.ogg")
else
print("|cFFFF9999 No new recipes found.|r")
end
scanSuccessful = true
end