Thread Tools Display Modes
04-01-19, 03:06 PM   #1
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
GameTooltip SetBagItem() not working for bank slots

My Bagnon plugin relys on scanning item tooltips.

However, it seems that
SetBagItem(self:GetBag(), self:GetID())
does have no effect for items in bank slots (self:GetBag() == -1).

I am using this SetHyperlink() workaround, but is there really no proper way?

(Sorry for not providing a minimum working example that would run without Bagnon. Maybe someone can tell me how to hook OnEnter for item slots in general?)

Code:
-- Tooltip used for scanning.
local scannerTooltip = CreateFrame("GameTooltip", "BagnonRequiredLevelScannerTooltip", nil, "GameTooltipTemplate")
scannerTooltip:SetOwner(WorldFrame, "ANCHOR_NONE")

-- Function to set the tooltip to the current item.
local SetTooltip = function(self)
  
  -- Skip non-item slots.
  if(not self:GetItem()) then return end

  -- Set the tooltip to current item.
  if (self:GetBag() == -1) then
    scannerTooltip:SetHyperlink(self:GetItem())
  else
    scannerTooltip:SetBagItem(self:GetBag(), self:GetID())
  end

  -- Print the first tooltip line.
  print(time(), _G[scannerTooltip:GetName().."TextLeft1"]:GetText())
  
end

hooksecurefunc(Bagnon.ItemSlot, "OnEnter", SetTooltip)
Thanks!
  Reply With Quote
04-01-19, 03:13 PM   #2
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Lua Code:
  1. GameTooltip:SetInventoryItem('player', slotID)

Where slotID is 40-67.

https://wow.gamepedia.com/API_GameTo...tInventoryItem
https://wow.gamepedia.com/InventorySlotId
  Reply With Quote
04-01-19, 03:50 PM   #3
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
Thanks for the quick reply!

I tried
Code:
  -- Set the tooltip to current item.
  if (self:GetBag() == -1) then
    scannerTooltip:SetInventoryItem('player', self:GetID()+39)
  else
    scannerTooltip:SetBagItem(self:GetBag(), self:GetID())
  end
but the tooltips for bank slots remain empty. Am I missing something?
  Reply With Quote
04-03-19, 02:23 PM   #4
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Try explicitly calling :Show() on the tooltip before attempting to read it.
  Reply With Quote
04-06-19, 04:03 PM   #5
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
Thanks again for your help!

It turned out that the error was something else:
Apparently, the slotIDs for bank are now 48-75.

When I changed the line in my code above to
Code:
scannerTooltip:SetInventoryItem('player', self:GetID()+47)
it worked fine!
  Reply With Quote
02-22-20, 07:33 AM   #6
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
As of 8.3 you need to do
Code:
scannerTooltip:SetInventoryItem('player', itemSlot:GetID()+51)
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
02-22-20, 12:38 PM   #7
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
I typically use BankButtonIDToInvSlotID() to get the offset.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
02-23-20, 05:23 AM   #8
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
Originally Posted by SDPhantom View Post
I typically use BankButtonIDToInvSlotID() to get the offset.
Hey, thanks! I did not know of this function. With it I do not have to manually hardcode the offset any more.
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » GameTooltip SetBagItem() not working for bank slots

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off