Thread Tools Display Modes
08/02/15, 09:40 AM   #1
Rhalyf
AddOn Author - Click to view addons
Join Date: Jul 2015
Posts: 12
ItemLink for moused over item in BAG_WORN

I'm sure I'm doing something stupid, but I can't seem to figure it out yet...

For my Glyph Tooltips AddOn, I get the info (bag/slot) I need to build the ItemLink from moc().dataEntry.data. dataEntry doesn't appear to be defined when mousing over equipped items (BAG_WORN). Am I going about this the wrong way?

Does anyone know of any AddOns that modify the tooltip for equipped items that I could look at the source for?

Thanks!

-Rhalyf.
  Reply With Quote
08/02/15, 09:52 AM   #2
Rhalyf
AddOn Author - Click to view addons
Join Date: Jul 2015
Posts: 12
I've thought of a kludgy way I can do this... I can do string comparisons on the control name since the name of the control for chest is 'ZO_CharacterEquipmentSlotChest'. It's gross but from there I can figure out the slotIndex and the the bagId is BAG_WORN...

If anyone can think of a better way for this, lemme know because this hurts me to code this lol
  Reply With Quote
08/02/15, 09:58 AM   #3
Wandamey
Guest
Posts: n/a
ItemTooltip.SetWornItem(self,slotIndex)

the method is just for the BAG_WORN so no need to redefine it in the args... take a look at the control page, section tootltips on the wiki

local yourfunction = ItemTooltip.SetWornItem
ItemTooltip.SetWornItem = function(self, slotIndex,...)
yourfunction(self,slotIndex,...)
doyourthings()
end
in the great lines.

sorry i forgot the essential :GetItemLink(BAG_WORN, slotIndex)
  Reply With Quote
08/02/15, 10:05 AM   #4
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
I'm not sure, if I got, what you want to do. But I think you want to take a look to:
GetEquippedItemInfo(index)
or want to hook
ItemTooltip:SetWornItem(index)
Originally Posted by Rhalyf View Post
I've thought of a kludgy way I can do this... I can do string comparisons on the control name since the name of the control for chest is 'ZO_CharacterEquipmentSlotChest'. It's gross but from there I can figure out the slotIndex and the the bagId is BAG_WORN...

If anyone can think of a better way for this, lemme know because this hurts me to code this lol
Edit 1: Got ninja'd by Wandamey
  Reply With Quote
08/02/15, 10:06 AM   #5
Rhalyf
AddOn Author - Click to view addons
Join Date: Jul 2015
Posts: 12
That's a lot more attractive, thanks!

-Rhalyf.


EDIT: I got ninja'd by votan. Thanks to you both.

Last edited by Rhalyf : 08/02/15 at 10:16 AM.
  Reply With Quote
08/02/15, 10:08 AM   #6
Wandamey
Guest
Posts: n/a
alternatively you can do whatever you want on a hook... edit the tooltip, launch a function to prepare the dinner, wait what time is it?
  Reply With Quote
08/02/15, 02:22 PM   #7
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
This was already answered, but I already have the code written in an addon so I'll copy & paste part of it as an example & add something to the other responses:
Lua Code:
  1. -- Function to add line to tooltip
  2. local function AddToolTipLine(ItemToolTip, bagId, slotIndex)
  3.     -- Get the slot data (if your only doing this for bag items)
  4.     local slotData = SHARED_INVENTORY:GenerateSingleSlotData(bagId, slotIndex)
  5.     local itemName = slotData.name
  6.     local newLine = zo_strformat("This item is called: <<1>>", itemName)
  7.    
  8.     ItemToolTip:AddLine(newLine, "ZoFontGame", 1, 0, 0, LEFT, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  9. end
  10.  
  11. -- Hook SetBagItem
  12. local hSetBagItem = ItemTooltip.SetBagItem
  13. ItemTooltip.SetBagItem = function(control, bagId, slotIndex, ...)
  14.     hSetBagItem(control, bagId, slotIndex, ...)
  15.     AddToolTipLine(control, bagId, slotIndex)
  16. end
  17.  
  18. -- Hook SetWornItem
  19. local hSetWornItem = ItemTooltip.SetWornItem
  20. ItemTooltip.SetWornItem = function(control, slotIndex, ...)
  21.     hSetWornItem(control, slotIndex, ...)
  22.     AddToolTipLine(control, BAG_WORN, slotIndex)
  23. end

Also if you /zgoo ItemTooltip, or look at: ingame/inventory/inventoryslot.lua & search for
Lua Code:
  1. -- Approximately line 1684 in version esoui 2.0.12
  2. local InventoryEnter =
  3. {
  4.     [SLOT_TYPE_QUEST_ITEM] =
  5.  ....
you can examine all of the slotTypes to see which set function they call, in case you want to do this with more slot types than just bag & worn. For example you may want to do this for trading house items as well:
Lua Code:
  1. local hSetTradingHouseBagItem = ItemTooltip.SetTradingHouseItem
  2. ItemTooltip.SetTradingHouseItem = function(control, tradingHouseSlotIndex, ...)
  3.     hSetTradingHouseBagItem(control, tradingHouseSlotIndex, ...)
  4.     AddToolTipLine(control, nil, , nil, tradingHouseSlotIndex)
  5. end
If you want to do it in the trading house, you can still use the same AddToolTipLine(..), but you have to get the link a different way:
Lua Code:
  1. local function AddToolTipLine(itemToolTip, bagId, slotIndex, TradingHouseSlotIndex)
  2.     if not JunkIt.SavedVariables["RESEARCHTOOLTIPS"] then return end
  3.    
  4.     local itemLink
  5.  
  6.     if bagId and slotIndex then
  7.         itemLink = GetItemLink(bagId, slotIndex)
  8.     elseif TradingHouseSlotIndex and TRADING_HOUSE:IsAtTradingHouse() then
  9.         if TRADING_HOUSE.m_searchResultsList and TRADING_HOUSE.m_searchResultsList.data and TRADING_HOUSE.m_searchResultsList.data[TradingHouseSlotIndex] then
  10.         itemLink = GetTradingHouseSearchResultItemLink(TradingHouseSlotIndex)
  11.         end
  12.     end
  13.    ...
And last I'll throw this out here, because I remember when I was doing this I made a type-o & couldn't figure out why I was getting strange results:
Lua Code:
  1. --returns "Elegant Hat" link (for me at least & no I don't even have one)
  2. GetItemLink(nil, nil)
  3.  
  4. -- returns "[Empty String]"
  5. GetItemLink(nil, <invalid slotIndex thats not nil>)
  6.  
  7. -- defaults to bagId == 1
  8. GetItemLink(<nil or invalid bagId>, <valid slotIndex>)
  9.  
  10. -- So don't try doing:
  11. if not itemLink then return end
  12. -- and thinking that will be a good check for all errors

Last edited by circonian : 08/02/15 at 07:54 PM.
  Reply With Quote
08/02/15, 07:18 PM   #8
Rhalyf
AddOn Author - Click to view addons
Join Date: Jul 2015
Posts: 12
Thanks for all the info guys. I've got some refactoring to do. :]

-Rhalyf.

EDIT: I was attempting to do this with PreHookHandlers and having to worry about race conditions and holy crap this is so much cleaner. Guess I'll be refactoring SousChef too :]

Last edited by Rhalyf : 08/02/15 at 07:45 PM.
  Reply With Quote
08/02/15, 08:18 PM   #9
Wandamey
Guest
Posts: n/a
Originally Posted by circonian View Post
...
Also if you /zgoo ItemTooltip, or look at: ingame/inventory/inventoryslot.lua & search for
...
If you're super bored some day you can also try to make a /zgoo mouse on the ItemTooltip
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » ItemLink for moused over item in BAG_WORN


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