Thread Tools Display Modes
03/14/16, 08:36 PM   #1
ziggr
 
ziggr's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 27
How to make GetAttachedItemInfo() work?

Is there an API to tell the ESO client to fetch email attachment data from the ESO server?

Before I open a message in the game's email viewer, attachment data is blank:
GetAttachedItemLink(mailID, 1)
=> [empty string]


After opening the message in the game's email viewer, attachment data is populated:
GetAttachedItemInfo(mailID, 1)
=> Diamond

I've tried a few permutations of various API calls to fetch attachment info from the server, nothing worked.
  • ReadMail(id64 mailId)
  • RequestReadMail(id64 mailId)
  • IsReadMailInfoReady(id64 mailId)

I just want to iterate through all mail messages and collect a list of attached items. It appears the current way to do that is to first ask the human to click each email to load its data from the server. Blech.
  Reply With Quote
03/15/16, 05:10 AM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
The click on a mail calls RequestReadMail(id64 mailId) and then waits for EVENT_MAIL_READABLE(eventId, mailId) to return. Once that event fires, you can read the attachments.
  Reply With Quote
03/15/16, 05:34 PM   #3
ziggr
 
ziggr's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 27
Thank you

Thank you for the tip.

Working on that now. Still not getting callbacks after _my_ ReqeustReadMail(), but do get callbacks if I click around in the Mail UI, so I'm still missing a step somewhere. Probably some subtle call sequence requirement or something. So I downloaded the ESO UI source so that see how ZOS makes it work.

Progress continues...
  Reply With Quote
03/16/16, 04:53 AM   #4
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
You can try something like this:
Lua Code:
  1. local function OpenNextMail(nextMailId)
  2.  nextMailId = GetNextMailId(nextMailId)
  3.  if(nextMailId) then
  4.   RequestReadMail(nextMailId)
  5.  end
  6. end
  7.  
  8. local function OnMailReadable(_, mailId)
  9.  -- process attachments
  10.  OpenNextMail(mailId)
  11. end
  12.  
  13. EVENT_MANAGER:RegisterForEvent(EVENT_MAIL_READABLE, OnMailReadable)
  14. OpenNextMail()

You also have to keep in mind that these functions only work while the mailbox is opened.
Either you only use it while the mail scene is showing, or you call RequestOpenMailbox() and CloseMailbox() yourself, but then you will also have to make sure that you don't call them when another addon or the UI is using the mailbox.
  Reply With Quote
03/25/16, 06:00 PM   #5
ziggr
 
ziggr's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 27
Woo! It works!

Thank you, sirinsidiator!

Originally Posted by sirinsidiator View Post
You also have to keep in mind that these functions only work while the mailbox is opened.
That was the last missing piece. Those API calls don't work so hot when the mailbox UI is closed. When the mailbox UI is open? They work like a champ.

--Z
  Reply With Quote
03/26/16, 11:52 AM   #6
Lodur
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 108
Best practice I think is to add it to the mail scene, because if not if someone closes the mail scene while your addon is doing it's thing you'll have a problem.

And if you open and close the mail box yourself, then your call to close can mess up the mail scene if it is open.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » How to make GetAttachedItemInfo() work?


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