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:
-- Function to add line to tooltip
local function AddToolTipLine(ItemToolTip, bagId, slotIndex)
-- Get the slot data (if your only doing this for bag items)
local slotData = SHARED_INVENTORY:GenerateSingleSlotData(bagId, slotIndex)
local itemName = slotData.name
local newLine = zo_strformat("This item is called: <<1>>", itemName)
ItemToolTip:AddLine(newLine, "ZoFontGame", 1, 0, 0, LEFT, MODIFY_TEXT_TYPE_NONE, LEFT, false)
end
-- Hook SetBagItem
local hSetBagItem = ItemTooltip.SetBagItem
ItemTooltip.SetBagItem = function(control, bagId, slotIndex, ...)
hSetBagItem(control, bagId, slotIndex, ...)
AddToolTipLine(control, bagId, slotIndex)
end
-- Hook SetWornItem
local hSetWornItem = ItemTooltip.SetWornItem
ItemTooltip.SetWornItem = function(control, slotIndex, ...)
hSetWornItem(control, slotIndex, ...)
AddToolTipLine(control, BAG_WORN, slotIndex)
end
Also if you /zgoo ItemTooltip, or look at: ingame/inventory/inventoryslot.lua & search for
Lua Code:
-- Approximately line 1684 in version esoui 2.0.12
local InventoryEnter =
{
[SLOT_TYPE_QUEST_ITEM] =
....
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:
local hSetTradingHouseBagItem = ItemTooltip.SetTradingHouseItem
ItemTooltip.SetTradingHouseItem = function(control, tradingHouseSlotIndex, ...)
hSetTradingHouseBagItem(control, tradingHouseSlotIndex, ...)
AddToolTipLine(control, nil, , nil, tradingHouseSlotIndex)
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:
local function AddToolTipLine(itemToolTip, bagId, slotIndex, TradingHouseSlotIndex)
if not JunkIt.SavedVariables["RESEARCHTOOLTIPS"] then return end
local itemLink
if bagId and slotIndex then
itemLink = GetItemLink(bagId, slotIndex)
elseif TradingHouseSlotIndex and TRADING_HOUSE:IsAtTradingHouse() then
if TRADING_HOUSE.m_searchResultsList and TRADING_HOUSE.m_searchResultsList.data and TRADING_HOUSE.m_searchResultsList.data[TradingHouseSlotIndex] then
itemLink = GetTradingHouseSearchResultItemLink(TradingHouseSlotIndex)
end
end
...
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:
--returns "Elegant Hat" link (for me at least & no I don't even have one)
GetItemLink(nil, nil)
-- returns "[Empty String]"
GetItemLink(nil, <invalid slotIndex thats not nil>)
-- defaults to bagId == 1
GetItemLink(<nil or invalid bagId>, <valid slotIndex>)
-- So don't try doing:
if not itemLink then return end
-- and thinking that will be a good check for all errors