WoWInterface (
-   Lua/XML Help (
-   -   GameTooltip SetBagItem() not working for bank slots (

LudiusMaximus 04-01-19 03:06 PM

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?)


-- 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:SetBagItem(self:GetBag(), self:GetID())

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

hooksecurefunc(Bagnon.ItemSlot, "OnEnter", SetTooltip)


p3lim 04-01-19 03:13 PM

Lua Code:
  1. GameTooltip:SetInventoryItem('player', slotID)

Where slotID is 40-67.

LudiusMaximus 04-01-19 03:50 PM

Thanks for the quick reply!

I tried

  -- Set the tooltip to current item.
  if (self:GetBag() == -1) then
    scannerTooltip:SetInventoryItem('player', self:GetID()+39)
    scannerTooltip:SetBagItem(self:GetBag(), self:GetID())

but the tooltips for bank slots remain empty. Am I missing something?

p3lim 04-03-19 02:23 PM

Try explicitly calling :Show() on the tooltip before attempting to read it.

LudiusMaximus 04-06-19 04:03 PM

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

scannerTooltip:SetInventoryItem('player', self:GetID()+47)
it worked fine!

LudiusMaximus 02-22-20 07:33 AM

As of 8.3 you need to do

scannerTooltip:SetInventoryItem('player', itemSlot:GetID()+51)

SDPhantom 02-22-20 12:38 PM

I typically use BankButtonIDToInvSlotID() to get the offset.

LudiusMaximus 02-23-20 05:23 AM


Originally Posted by SDPhantom (Post 335190)
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.

All times are GMT -6. The time now is 03:47 AM.

vBulletin © 2021, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI