View Single Post
02/13/23, 06:23 AM   #9
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
I see you have understood it

You can simply these kind of "if ..." code:
Code:
if (GetItemLinkItemType(linkFunc(...)) == ITEMTYPE_ARMOR) or (GetItemLinkItemType(linkFunc(...)) == ITEMTYPE_WEAPON) then -- Check if item is armor or a weapon (visual equipment with styles)
Build a local lookup table with the key = allowed itemTypes and value = boolean true, and then just check for if lookupTable[itemType] then
Lua Code:
  1. local allowedItemtypes = {
  2.  [ITEMTYPE_ARMOR] = true,
  3.  [ITEMTYPE_WEAPON] = true  
  4. }
  5.  
  6. if (allowedItemtypes[GetItemLinkItemType(linkFunc(...))] then -- Check if item is armor or a weapon (visual equipment with styles)
  7. ...
  8. end


And if you need linkFunc(...) more than once define a local like
local itemLink = linkFunc(...)
and then reuse itemLink instead of calling the function again and again and ...


For your other questions:
I never worked with the styles and motifs but there exist several API functions where you pass in an itemLink or bagId, slotIndex and you will get the needed info in return.
I guess IsItemLinkBookKnown(itemLink) could help you here for example


Search the API txt documentation file for "known" and you should find several functions that may help. Not sure if the IsItemLinkBookKnown also works on normal style books without motif pages, I hope so.

Last edited by Baertram : 02/13/23 at 06:26 AM.
  Reply With Quote