View Single Post
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