Skip to content

Instantly share code, notes, and snippets.

@nefftd
Created January 16, 2015 17:23
Show Gist options
  • Save nefftd/222f83b651aa05d8b3af to your computer and use it in GitHub Desktop.
Save nefftd/222f83b651aa05d8b3af to your computer and use it in GitHub Desktop.
local tooltip
local function create_tooltip()
local tip, fontstrings = CreateFrame("GameTooltip", "temptt"), {}
for i = 1, 8 do
local L,R = tip:CreateFontString(), tip:CreateFontString()
L:SetFontObject(GameFontNormal)
R:SetFontObject(GameFontNormal)
tip:AddFontStrings(L,R)
table.insert(fontstrings,L)
table.insert(fontstrings,R)
end
tip.fontstrings = fontstrings
return tip
end
local function is_soulbound_item(bag, slot) -- returns boolean
tooltip = tooltip or create_tooltip()
tooltip:SetHyperlink('item:')
tooltip:SetOwner(UIParent,"ANCHOR_NONE")
tooltip:SetBagItem(bag, slot)
for i,v in ipairs(tooltip.fontstrings) do
if v:GetText() == ITEM_SOULBOUND then
return true
end
end
return false
end
local itemId = GetContainerItemID(0, 1)
print("HS: "..itemId) -- Hearthstone is at 0,1
local soulbound = is_soulbound_item(0, 1)
if soulbound then
print("Soulbound")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment