ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Detect item was received from a bag? (https://www.esoui.com/forums/showthread.php?t=10782)

Solution_Lop 01/10/24 01:36 PM

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!

Dolgubon 01/10/24 02:02 PM

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.

Solution_Lop 01/10/24 02:35 PM

Quote:

Originally Posted by Dolgubon (Post 49188)
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 :(

Baertram 01/10/24 04:39 PM

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

Solution_Lop 01/11/24 05:35 AM

Quote:

Originally Posted by Baertram (Post 49190)
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.

Baertram 01/11/24 08:25 AM

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.


All times are GMT -6. The time now is 09:45 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI