View Single Post
02/06/17, 03:41 PM   #1
Klingo
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 16
Get ItemType from LootItemType

Hi

I was looking for a way to figure out what type of items are lootable from any given container.

With [EVENT_LOOT_UPDATED] I know exactly when the loot window opens and I can also loop through all lootable items. With "GetLootItemInfo()" I then can get the LootItemType, which for clothing materials etc. is always [LOOT_TYPE_ANY]. But what I actually would want to have is the real itemType, which in case for e.g. "Jute" would be [ITEMTYPE_CLOTHIER_RAW_MATERIAL].

Since "GetLootItemInfo()" was no success, I thought it might be possible to use the "GetItemLinkItemType()" method and then get the information via the itemLink from the lootItem... but this also just returns the LootItemType [LOOT_TYPE_ANY].

This is my code example:
Lua Code:
  1. local lootCount =  GetNumLootItems()
  2. for i = 0, lootCount - 1 do
  3.     local _, name, _, _, _, _, _, _, lootItemType = GetLootItemInfo(i)
  4.  
  5.     CHAT_SYSTEM:AddMessage("lootItemType = " .. lootItemType)
  6.  
  7.     local link = GetLootItemLink(i)
  8.     local itemType = GetItemLinkItemType(link)
  9.  
  10.     CHAT_SYSTEM:AddMessage("itemType = " .. itemType)
  11. end

Which generates the following chat output (for e.g. "Jute"):
Code:
lootItemType = 0
itemType = 0

Is it even possible to know what ItemType a lootable item is... before looting it?
I mean in a reasonable way and not with hundreds of lines of code to check for every possible name of the item (although that would work)

Klingo
  Reply With Quote