View Single Post
05-09-14, 07:16 PM   #14
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You should always use itemIDs anyway. Using item names has a number of flaws, such as restricting your addon to only work in English game clients, failing for items you haven't seem during your play session, etc. IDs are better in every way.

If you really need to compare strings against item names, rather than calling GetItemInfo every time, call it once and store the result in a variable outside of whatever function you're comparing in, then use the variable inside that function:
local SHA_CRYSTAL = GetItemInfo(74248)
Or use GetLootSlotLink instead of GetLootSlotInfo and extract the itemID from the link:
local link = GetLootSlotLink(i)
local id = link and tonumber(strmatch(link, "item:(%d+)"))
However, without knowing your actual goals (eg. why you want to know whether an item is used for enchanting, and what you want to do with that knowledge), it's hard to really offer any specific useful suggestions.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote