Thread Tools Display Modes
05/02/14, 05:53 AM   #1
Riksis
 
Riksis's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 2
Question Item quality and traits on loot received

Hello everybody,

right now I try to determine two values of an item at loot time, the item quality (trash) and if it has the ornate trait (perhaps later other values as well, right now it's these two).

I know there are the functions that I can call with an item in my bag, however my current attempt is to listen to EVENT_LOOT_RECEIVED, there I get a link to the item.

Right now my main source of information is the wiki here on http://wiki.esoui.com/API. The only method that I find that takes a link is GetItemLinkInfo(), which does not give these information.

In http://www.esoui.com/forums/showthread.php?t=1297 Garkin posted a way to get an itemID from the link. But from my understanding of what is written in that thread this ID is not an ID specific to my item but to the item template, so no use for me.

Is there a way to obtain the values I need from the item link, or do I have to try matching new items in the inventory with items I just looted?

Thanks
Riksis
  Reply With Quote
05/02/14, 06:06 AM   #2
Teli
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 19
Post

There are is a function that may help you

ZO_LinkHandler_ParseLink
it's the same parameters as ZO_LinkHandler_CreateLink. You can get more info about it here

you could try
Lua Code:
  1. local  name, color, linkType,data = ZO_LinkHandler_ParseLink(link)
  2.  
  3. --add parse out the data using
  4. local index = 1
  5. local itemAttributes = {}
  6. for value in string.gmatch(data,":") do  
  7.    itemAttributes[index] = value
  8.    index = index + 1
  9. end
  10. -- itemAttributes[1]  equals ItemID
  11. -- itemAttributes[2]  equals Quality
  12. -- itemAttributes[3]  equals Level Requirement
  Reply With Quote
05/02/14, 11:24 AM   #3
Sephiroth018
 
Sephiroth018's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 20
It may be easier to use the event EVENT_INVENTORY_SINGLE_SLOT_UPDATE and check for isNewItem, which is true when the item is added to your inventory.
Lua Code:
  1. function InventorySingleSlotUpdate(eventCode, bagId, slotId, isNewItem, itemSoundCategory, updateReason)
You can then use some more functions to get all informations about the item (copied from the wiki):
Lua Code:
  1. GetItemLevel(integer bagId, integer slotIndex)
  2.     Returns: integer level
  3. GetItemTrait(integer bagId, integer slotIndex)
  4.     Returns: ItemTraitType trait
  5. GetItemInfo(integer bagId, integer slotIndex)
  6.     Returns: textureName icon, integer stack, integer sellPrice, bool meetsUsageRequirement, bool locked, integer equipType, integer itemStyle, integer quality
  7. GetItemType(integer bagId, integer slotIndex)
  8.     Returns: ItemType itemType
As far as i know, this is the only way to get itemType and traitType from looted items.
  Reply With Quote
05/02/14, 11:50 AM   #4
Riksis
 
Riksis's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 2
Thank you both for your answers.

@Teli:
I'll definitely have a look into the ZO_LinkHandler_ParseLink link you posted. Might be worth a try.

@Sephiroth018
My issue with EVENT_INVENTORY_SINGLE_SLOT_UPDATE is that it also gets triggered at other times as well, when I trade, get mail, etc. I want to create some statistics how different sources of gold compare (coin loot, quest rewards, dropped item values). Therefore I must only trigger this on items that I loot and ignore all other sources of gaining items. And I don't want to flat out count all items as a lot I don't sell (e.g. item deconstruction) and don't want to count in my gold statistics.

Right now I resorted to plainly use merchant coin gain. Might or might not be enough for my intentions, I'll have to see.
  Reply With Quote
05/02/14, 03:16 PM   #5
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
The other option you can do is monitor the Loot Interaction in a frames update routine.

I use it in my gatherer addon to monitor loot taken after a loot interaction after a harvest interaction.

If you want to take a look at how I use it feel free to look at the NodeInteract files in my addon.
  Reply With Quote
05/03/14, 01:13 AM   #6
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 642
Check out this post and this link.
  Reply With Quote
05/03/14, 03:07 AM   #7
Iyanga
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 183
Originally Posted by Riksis View Post
My issue with EVENT_INVENTORY_SINGLE_SLOT_UPDATE is that it also gets triggered at other times as well, when I trade, get mail, etc.
Originally Posted by Xrystal View Post
The other option you can do is monitor the Loot Interaction in a frames update routine.
I use it in my gatherer addon to monitor loot taken after a loot interaction after a harvest interaction.

OR you can just use the approach I do in Lootlog:

You use both events, store the item details during the EVENT_INVENTORY_SINGLE_SLOT_UPDATE, but process the details only when the LOOT event fires. Yes, the inventory update happens before the loot event.

Works like a charm for weeks and everything I've obtained since then.
  Reply With Quote
05/03/14, 03:18 AM   #8
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Riksis View Post
Thank you both for your answers.

@Teli:
I'll definitely have a look into the ZO_LinkHandler_ParseLink link you posted. Might be worth a try.

@Sephiroth018
My issue with EVENT_INVENTORY_SINGLE_SLOT_UPDATE is that it also gets triggered at other times as well, when I trade, get mail, etc. I want to create some statistics how different sources of gold compare (coin loot, quest rewards, dropped item values). Therefore I must only trigger this on items that I loot and ignore all other sources of gaining items. And I don't want to flat out count all items as a lot I don't sell (e.g. item deconstruction) and don't want to count in my gold statistics.

Right now I resorted to plainly use merchant coin gain. Might or might not be enough for my intentions, I'll have to see.
If you want to create statistics, I think that you can use EVENT_MONEY_UPDATE. It gives all information you need.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Item quality and traits on loot received


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