WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Determine if an item is soulbound (https://www.wowinterface.com/forums/showthread.php?t=56828)

doofus 11-04-18 01:42 AM

Determine if an item is soulbound
 
I am parsing the tooltip for gear in my bags, and for each item it tells me either "Binds when picked up" or "Binds when equipped". It does that on gear that's either used/soulbound or unused in the bags.

For "Binds when equipped" gear, is there a way to find if it has been used, ie has become soulbound?

Rilgamon 11-04-18 02:07 AM

Your tooltip should show it.
This is taken from my addon ...

Lua Code:
  1. local cTip = CreateFrame("GameTooltip","PrivTooltip",nil,"GameTooltipTemplate")
  2. local function IsSoulbound(bag, slot)
  3.     cTip:SetOwner(UIParent, "ANCHOR_NONE")
  4.     cTip:SetBagItem(bag, slot)
  5.     cTip:Show()
  6.     for i = 1,cTip:NumLines() do
  7.         if(_G[name.."TooltipTextLeft"..i]:GetText()==ITEM_SOULBOUND) then
  8.             cTip:Hide()
  9.             return true
  10.         end
  11.     end
  12.     cTip:Hide()
  13.     return false
  14. end

doofus 11-04-18 03:33 AM

Thanks, I need to try that.

Currently I am using ...

-- https://wow.gamepedia.com/API_GetCursorInfo
local infoType, cursorItemID, cursorItemLink = GetCursorInfo();

... because the item is on the cursor.

I am also using the "GET_ITEM_INFO_RECEIVED" event and the "CHAT_MSG_LOOT" messages to get hold of item strings, therefore the items may not in my bags at all.

Therefore for the tooltip I use

GameTooltip:SetOwner(UIParent,"ANCHOR_NONE");
GameTooltip:SetHyperlink(itemLink);

Kemayo 11-04-18 02:25 PM

You can do this without tooltip scanning now, with the C_Item APIs:


Code:

C_Item.IsBound(ItemLocation:CreateFromBagAndSlot(bag, slot))


All times are GMT -6. The time now is 12:28 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI