View Single Post
04/27/19, 01:37 PM   #3
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 132
Thumbs up

Originally Posted by sirinsidiator View Post
Not sure what you mean with ZO_LinkHandler_CreateChatLink is "unexposed"? It is a global function defined in zo_linkhandler.lua, but you won't need it for getting the attachment name, since all it basically does is call the function that is passed to it.

Reading mailinbox_keyboard.lua you can see how the attachment slots are created. The important part is where ZO_Inventory_BindSlot is called with SLOT_TYPE_MAIL_ATTACHMENT. This determines what happens when you interact with that item slot. When you search the inventoryslot.lua for that slot type, you can see that it passes GetAttachedItemLink, MAIL_INBOX:GetOpenMailId() and ZO_Inventory_GetSlotIndex(inventorySlot) to ZO_LinkHandler_CreateChatLink.

This means calling GetAttachedItemLink(MAIL_INBOX:GetOpenMailId(), ZO_Inventory_GetSlotIndex(inventorySlot)) will give you the item link for the attachment and from there you can use any of the item link functions to extract whatever info you need.

(If you follow that definition, you get linkFunction() which again is meaningless. Doesn't tell me how to get the name without a bagId.)

I was going to say that I had already tracked into SLOT_TYPE_MAIL_ATTACHMENT, when I clicked GetAttachedItemLink again, and again seeing no definition - but this time clicking on the single reference mentioned there. Ironically, a line below that reference has GetItemLinkName() which gives me a solution.

A convoluted and awkward solution, but it does work! Thanks again siri.

tl;dr
Code:
local link = GetAttachedItemLink(MAIL_INBOX:GetOpenMailId(), ZO_Inventory_GetSlotIndex(inventorySlot), LINK_STYLE_DEFAULT)
local name = GetItemLinkName(link)

ESO DEVELOPERS: Would be nice if the Control just had this .name in a .data, like the inventory does. How come it doesn't?

Last edited by Phuein : 04/27/19 at 02:01 PM.
  Reply With Quote