Thread Tools Display Modes
01/10/24, 01:36 PM   #1
Solution_Lop
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 5
Detect item was received from a bag?

Hello, dear community!

My task was to determine if the item was obtained from a bag obtained during the daily crafting tasks. I'm interested in whether there are ways to programmatically determine the origin of an item in the add-on code for Elder Scrolls Online. In particular, I need to distinguish between items obtained from pouches of different professions.

I will be grateful for any hints, and if anyone has any experience or ideas on this issue, please share!

Thanks!
  Reply With Quote
01/10/24, 02:02 PM   #2
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 409
Unfortunately, this is a question with a very annoying answer. Which is 'no, but kind of yes, and also the yes is a pain in the ass'
Eso has a 'new item' event, but it does not differentiate between a new item from say a chest or from a writ container.It doesn't even tell you that it was from a chest.
Then there's the actual containers. Well, there's no way to determine if a container is a writ container programmatically, you need to just say 'oh yeah the name is the same as a writ container.' Which is a pain for localization. And needing a string comparison is annoying. The string comparison is made even more annoying because it uses Roman numerals to signify the level of the reward. So you need to deal with that Roman numeral, unless you just don't care. Then, did you already open the container and just didn't loot it (or were unable to loot it because your inventory was full?)
Well screw you there's no indication of that. Which means you can't just save the contents when you view them, that would be too easy.
So you need to setup a system where you have a buffer table. And in that table you save items you see in a viewed container. And then when the new item event fires you need to check the buffer table first.
But oh wait because there's no indication of where that new item came from, it could come from crafting, from a mail, from another writes reward box, space, who knows. So you've don't aaaaaaall this work and in the end you're only pretty sure it was looted from a writ container.




Yeah. Not. A. Fan.


Iirc, the code relating to this is in LootHandler.lua in writ crafter. There's definitely holes and bugs in it, every so often I get mails of miscounting in the writ crafter Stats.
  Reply With Quote
01/10/24, 02:35 PM   #3
Solution_Lop
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 5
Originally Posted by Dolgubon View Post
Unfortunately, this is a question with a very annoying answer. Which is 'no, but kind of yes, and also the yes is a pain in the ass'
Eso has a 'new item' event, but it does not differentiate between a new item from say a chest or from a writ container.It doesn't even tell you that it was from a chest.
Then there's the actual containers. Well, there's no way to determine if a container is a writ container programmatically, you need to just say 'oh yeah the name is the same as a writ container.' Which is a pain for localization. And needing a string comparison is annoying. The string comparison is made even more annoying because it uses Roman numerals to signify the level of the reward. So you need to deal with that Roman numeral, unless you just don't care. Then, did you already open the container and just didn't loot it (or were unable to loot it because your inventory was full?)
Well screw you there's no indication of that. Which means you can't just save the contents when you view them, that would be too easy.
So you need to setup a system where you have a buffer table. And in that table you save items you see in a viewed container. And then when the new item event fires you need to check the buffer table first.
But oh wait because there's no indication of where that new item came from, it could come from crafting, from a mail, from another writes reward box, space, who knows. So you've don't aaaaaaall this work and in the end you're only pretty sure it was looted from a writ container.




Yeah. Not. A. Fan.


Iirc, the code relating to this is in LootHandler.lua in writ crafter. There's definitely holes and bugs in it, every so often I get mails of miscounting in the writ crafter Stats.
Thank you very much for the answer, I also ran into this problem.. I searched through almost all the APIs in order to somehow catch the very event at which the item is obtained. I spent a lot of time and most likely I will have to tinker with the tables
  Reply With Quote
01/10/24, 04:39 PM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
https://wiki.esoui.com/EVENT_INVENTO...LE_SLOT_UPDATE

This should be the event that triggers if any item get's into your BAG_BACKPACK (from loot etc.) but be carefull, it also triggers if anything happens with the items like durability of worn items changes, or stack is split in inventory, etc.
So add event filters there to "isNew" e.g.. Event filters are described here:
https://wiki.esoui.com/AddFilterForEvent
  Reply With Quote
01/11/24, 05:35 AM   #5
Solution_Lop
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 5
Originally Posted by Baertram View Post
https://wiki.esoui.com/EVENT_INVENTO...LE_SLOT_UPDATE

This should be the event that triggers if any item get's into your BAG_BACKPACK (from loot etc.) but be carefull, it also triggers if anything happens with the items like durability of worn items changes, or stack is split in inventory, etc.
So add event filters there to "isNew" e.g.. Event filters are described here:
https://wiki.esoui.com/AddFilterForEvent
Yes, I was considering this event, but I couldn't figure out how to determine the source of the item, that is, whether it was obtained, for example, from an alchemical bag.
  Reply With Quote
01/11/24, 08:25 AM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
You can't for "looted items"! As Dolgubon explained above.

You can, if: You withdraw an item from bank and it get's to your bagpack (or craftbag to backpack, or the other way around) it should fire 2 events though: 1 for from bag and 1 for to bag.
-> Unless that was changed since I last checked and used it.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Detect item was received from a bag?


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