Thread Tools Display Modes
08/11/14, 06:06 PM   #1
Waboku
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 6
Event_loot_received

Hello,
I'm trying to get a function to execute on event_loot_received but only if the item type is a recipe. Is that even possible? GetItemLinkItemType looks promising but I couldn't get it to work, most likely due to me not using it correctly. I tried using something like "function() if itemType == ITEMTYPE_RECIPE then ....." but I can't seem to get the itemType when I loot a recipe. Any help is appreciated.
  Reply With Quote
08/11/14, 06:57 PM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Here's a handler that should work:
Lua Code:
  1. local function onLootReceived(eventCode, lootedBy, itemLink, quantity, itemSound, lootType, lootedBySelf)
  2.     local itemType = GetItemLinkItemType(itemLink)
  3.     if itemType == ITEMTYPE_RECIPE then
  4.         ...
  5.     end
  6. end
  Reply With Quote
08/11/14, 06:59 PM   #3
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by Waboku View Post
Hello,
I'm trying to get a function to execute on event_loot_received but only if the item type is a recipe. Is that even possible? GetItemLinkItemType looks promising but I couldn't get it to work, most likely due to me not using it correctly. I tried using something like "function() if itemType == ITEMTYPE_RECIPE then ....." but I can't seem to get the itemType when I loot a recipe. Any help is appreciated.
Sous Chef has a function that marks unknown recipes with a "Check" mark.
  Reply With Quote
08/11/14, 07:15 PM   #4
Waboku
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 6
Originally Posted by merlight View Post
Here's a handler that should work:
Lua Code:
  1. local function onLootReceived(eventCode, lootedBy, itemLink, quantity, itemSound, lootType, lootedBySelf)
  2.     local itemType = GetItemLinkItemType(itemLink)
  3.     if itemType == ITEMTYPE_RECIPE then
  4.         ...
  5.     end
  6. end

Thanks merlight. I made the mistake of putting "local itemtype = getitemlinkitemtype" outside of the function. Don't know what possessed me to do such a thing. I got the code to work within the eventmanager:registerforevent call.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Event_loot_received

Thread Tools
Display Modes

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