Thread Tools Display Modes
04/17/14, 09:40 AM   #1
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
GetItemLinkInfo - need help for LootDrop

Hello,

Loot drop is using
Code:
local icon, _, _, _, _ = GetItemLinkInfo( itemName )
with the event
Code:
self.control:RegisterForEvent( EVENT_LOOT_RECEIVED, function( _, ... ) self:OnItemLooted( ... )    end )
But sometimes, icon information is missing.
(In fact alway when it's a quest item that is looted)

for the moment the workaround is
Code:
    if ( not icon or icon == '' ) then
        icon = [[/esoui/art/icons/icon_missing.dds]]
    end
How could have i the icon name ?
There is an icon im my bag, so how should i do to take it with the loot event ?
  Reply With Quote
04/17/14, 11:43 AM   #2
BadVolt
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 74
Originally Posted by Flagrick View Post
Hello,

Loot drop is using
Code:
local icon, _, _, _, _ = GetItemLinkInfo( itemName )
with the event
Code:
self.control:RegisterForEvent( EVENT_LOOT_RECEIVED, function( _, ... ) self:OnItemLooted( ... )    end )
But sometimes, icon information is missing.
(In fact alway when it's a quest item that is looted)

for the moment the workaround is
Code:
    if ( not icon or icon == '' ) then
        icon = [[/esoui/art/icons/icon_missing.dds]]
    end
How could have i the icon name ?
There is an icon im my bag, so how should i do to take it with the loot event ?
There are several ways to get link, like GetQuestRewardItemLink(). You can try this.
  Reply With Quote
04/18/14, 02:01 AM   #3
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
hello,
and thx for the reply.

The events parameters are these
Code:
EVENT_LOOT_RECEIVED (string receivedBy, string itemName, integer quantity, integer itemSound, integer lootType, bool self)
in case of quest item, then lootType = LOOT_TYPE_QUEST_ITEM
ok
but how could i use these parameters to link with

Code:
GetQuestRewardItemLink(luaindex rewardIndex, LinkStyle linkStyle)
Returns: string link
and what are
  • rewardIndex
  • linkStyle
  Reply With Quote
04/18/14, 09:37 AM   #4
Iyanga
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 183
Originally Posted by Flagrick View Post
in case of quest item, then lootType = LOOT_TYPE_QUEST_ITEM
ok
but how could i use these parameters to link with

Code:
GetQuestRewardItemLink(luaindex rewardIndex, LinkStyle linkStyle)
Returns: string link

You need to distinguish two cases!

The first one are items that are part of the quest, you know: Gather 4 garblknorps. For the garblknorps you have the LOOT_TYPE_QUEST_ITEM set. The second part are items as reward. Those come up as normal LOOT_TYPE_ITEM event!
  Reply With Quote
04/18/14, 12:12 PM   #5
ckaotik
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 12
Originally Posted by Flagrick View Post
GetQuestRewardItemLink(luaindex rewardIndex, LinkStyle linkStyle)
what are
  • rewardIndex
  • linkStyle
Well, rewardIndex is the index for which quest reward you are asking information. A quest might reward more than one thing, e.g. one or more items, a skill point or whatever. For most quests (that I have encountered so far) it seems there's only one item reward, i.e. rewardIndex = 1 will be your friend.

About linkStyle: There are two ways item links can be returned, check the wiki.
Code:
"[This is a fancy item]" -- LINK_STYLE_BRACKETS
"This is a fancy item" -- LINK_STYLE_DEFAULT
  Reply With Quote
05/01/14, 03:36 AM   #6
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
After this event
Code:
EVENT_LOOT_RECEIVED (string receivedBy, string itemName, integer quantity, integer itemSound, integer lootType, bool self)
I have try something like that
Code:
if (lootType == LOOT_TYPE_ITEM) then
  EasyFind(...)
end
elseif (lootType == LOOT_TYPE_QUEST_ITEM) then
  HardQuestFind(...)
end
in EasyFind() i'm using loot info or, if it's not enough to get icon, bag info.
in HardQuestFind(), not yet implemented,
is there a way to avoid the management and monitoring of quests.
I think that is a bit heavy to only have the icon, right?
  Reply With Quote
05/01/14, 04:35 AM   #7
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
I have somewhat similar problem. In my add-on I have a little code which just prints the loot to the chat with d().

That event gives us itemName, it is cool. But I wasn't able to link it to any other function, in order to get the quality of it. Same goes for the icon, I mean both the quality and the icon, you can get via GetLootItemInfo(), but I have no clue how to obtain the lootId.
  Reply With Quote
05/01/14, 05:33 AM   #8
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
I think there is something to do with it
Code:
EVENT_QUEST_TOOL_UPDATED (luaindex journalIndex, string questName)
we have journalIndex.

then, perhaps, we could find the questTool info with a loop on toolindex (0 to 10 for example)
Code:
GetQuestToolInfo(luaindex journalQuestIndex, luaindex toolIndex)
Returns: string iconFilename, integer stackCount, bool isUsable, string name
then a comparison on name could do the job to be sure we've got our quest item

I will try it.
  Reply With Quote
05/01/14, 12:52 PM   #9
Iyanga
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 183
*nudge, nudge* Lootlog *nudge, nudge*
  Reply With Quote
05/03/14, 12:42 PM   #10
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
Originally Posted by Iyanga View Post
*nudge, nudge* Lootlog *nudge, nudge*
Thx,
but i search to easily find icon quest tool info, and not the quest rewards.

As i said before it is done.
Code:
if (lootType == LOOT_TYPE_ITEM) then
  EasyFind(...)
end
elseif (lootType == LOOT_TYPE_QUEST_ITEM) then
  HardQuestFind(...)
end
in EasyFind() i'm using loot info or, if it's not enough to get icon, bag info.
For the second part the tools item quest i have used
Code:
EVENT_QUEST_TOOL_UPDATED (luaindex journalIndex, string questName)
but it seems to do nothing for my purpose.
But i will perssist ;-)

next step, i will test
Code:
EVENT_QUEST_CONDITION_COUNTER_CHANGED (luaindex journalIndex, string questName, string conditionText, integer conditionType, integer currConditionVal, integer newConditionVal, integer conditionMax, bool isFailCondition, string stepOverrideText, bool isPushed, bool isComplete, bool isConditionComplete, bool isStepHidden)

Last edited by Flagrick : 05/03/14 at 01:16 PM.
  Reply With Quote
05/03/14, 12:57 PM   #11
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Originally Posted by lyravega View Post
I have somewhat similar problem. In my add-on I have a little code which just prints the loot to the chat with d().

That event gives us itemName, it is cool. But I wasn't able to link it to any other function, in order to get the quality of it. Same goes for the icon, I mean both the quality and the icon, you can get via GetLootItemInfo(), but I have no clue how to obtain the lootId.
Lua Code:
  1. for i = 1,GetNumLootItems() do
  2.      local lootID, lootName, lootIcon, lootCount, lootQuality, lootValue, lootIsQuest = GetLootItemInfo(i)
  3. end
  Reply With Quote
05/03/14, 02:22 PM   #12
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
Originally Posted by Xrystal View Post
Lua Code:
  1. for i = 1,GetNumLootItems() do
  2.      local lootID, lootName, lootIcon, lootCount, lootQuality, lootValue, lootIsQuest = GetLootItemInfo(i)
  3. end
Thx,
i have try this after an EVENT_LOOT_RECEIVED
Code:
	dbg('--GetNumLootItems--')
	local count=GetNumLootItems()
	dbg(count)
	for i = 1,count do
		local lootID, lootName, lootIcon, lootCount, lootQuality, lootValue, lootIsQuest = GetLootItemInfo(i)
		local textQuestTool, cQuestTool = self:ParseLink( lootName )
		dbg(lootName)
		dbg(lootIcon)
	end
dbg is my d(...) function ;-)


But it seems to do not work
because when i loot a quest tool item, GetNumLootItems() send me ==> 0

but EVENT_QUEST_CONDITION_COUNTER_CHANGED is always sent ...
  Reply With Quote
05/03/14, 02:49 PM   #13
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Hmm, guess questTools are handled differently. I always get a number when I loot and there is something there but my addon deals with crafting materials so maybe different. Will have to test that theory out on a quest that involves looting something and see if I get the same problem.

Also, I notice you are using ParseLink function but passing a name string to it. That won't work as far as I know. You would have to use the GetLootLink(lootIndex) function ( wording from memory ).
  Reply With Quote
05/03/14, 05:36 PM   #14
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Well, the attached is my mini test addon I use to test things out. I've got it coded to track loot interactions and displays any loot you gather however it seems that quest Items do not have links like regular items. The screenshot shows what happens when I loot quest items.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20140503_234722.jpg
Views:	569
Size:	359.8 KB
ID:	215  
Attached Files
File Type: zip XrysTester.zip (1.7 KB, 467 views)
  Reply With Quote
05/03/14, 08:18 PM   #15
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
Originally Posted by Iyanga View Post
*nudge, nudge* Lootlog *nudge, nudge*
Thank you very much. I learned about that "ZO_LinkHandler_ParseLink" thanks to you
  Reply With Quote
05/04/14, 08:57 AM   #16
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
Originally Posted by Xrystal View Post
it seems that quest Items do not have links like regular items.
Yes that's the problem :-)

So with a loot event i could have text and quantity, but no icon, and of course, it is what i need.
With bag event i could have quest reward item but no tool quest item

This tools items are not in a bag, but in a sort of "quest manager".
for example InventoryGridView Addon doesn't handle with tools quest part in our inventory,
because there are not really in a bag.

I know to manage a sort of quest tracker, and then handle with tool quest item,
but i think it's a bit heavy to only show icon loot of tools quest item.
I'm searching a simpliest way, but perhaps there's not.
  Reply With Quote
05/04/14, 09:01 AM   #17
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Hmm the GetLootItemInfo should return the icon, but of course, if there isn't a link there may not be an icon associated at that time either but seeing as it is displayed in the loot window there is a chance that the icon will exist.

I didn't test the icon part as I thought the link is what you wanted. Might be worth displaying the icon and see what happens when you loot a quest item.
  Reply With Quote
05/04/14, 01:39 PM   #18
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
I think i have found something :

i' m using these events
  • EVENT_QUEST_TOOL_UPDATED
  • EVENT_QUEST_CONDITION_COUNTER_CHANGED
and i'm saving journalIndex

Then on an event EVENT_LOOT_RECEIVED ( receivedBy, itemName, quantity, itemSound, lootType, mine )
i'm testing GetItemLinkInfo(itemName)
if i do not have icon, i m testing saved informations from bag event
and if no icon then saved information with quest event (journalIndex)
Code:
local count=GetQuestToolCount(self.journalIndex)
		for i = 0, count do
			local iconFilename, stackCount, isUsable, name = GetQuestToolInfo(self.journalIndex, i)
			if (name==text) then
				icon=iconFilename
				break;
			end
		end
text is given by EVENT_LOOT_RECEIVED
and icon is the result i will used to print a lootdrop item

So, to test i have to find a quest with tools items to collect.
if it works (or not) i will say it

Last edited by Flagrick : 05/05/14 at 02:36 AM.
  Reply With Quote
05/06/14, 01:56 AM   #19
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
Originally Posted by Flagrick View Post
I think i have found something :

i' m using these events
  • EVENT_QUEST_TOOL_UPDATED
  • EVENT_QUEST_CONDITION_COUNTER_CHANGED
and i'm saving journalIndex

Then on an event EVENT_LOOT_RECEIVED ( receivedBy, itemName, quantity, itemSound, lootType, mine )
i'm testing GetItemLinkInfo(itemName)
if i do not have icon, i m testing saved informations from bag event
and if no icon then saved information with quest event (journalIndex)
Code:
local count=GetQuestToolCount(self.journalIndex)
		for i = 0, count do
			local iconFilename, stackCount, isUsable, name = GetQuestToolInfo(self.journalIndex, i)
			if (name==text) then
				icon=iconFilename
				break;
			end
		end
text is given by EVENT_LOOT_RECEIVED
and icon is the result i will used to print a lootdrop item

So, to test i have to find a quest with tools items to collect.
if it works (or not) i will say it
Sadly, it seems, it doesn't work with this events.
But i have found something else.
I'm testing. I ll give more info later.
  Reply With Quote
05/09/14, 04:36 AM   #20
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
Post

Originally Posted by Flagrick View Post
Sadly, it seems, it doesn't work with this events.
But i have found something else.
I'm testing. I ll give more info later.
so, it's the code, and it seems to work except in rare case (no icon in the quest inventory with a loot event)
I'm playing this code in a loot event.
I ve got the text name of the item quest, and then i find the icon that match with the name
Code:
function LootDrop:FindAndPrintAllIconFromQuestTools(text)
	local icon=[[/esoui/art/icons/icon_missing.dds]]
	local found=false
	local countQuests=GetNumJournalQuests()
	for i = 0, countQuests do
		local countTools=GetQuestToolCount(i)
		for j = 0, countTools do
			local iconFilename, stackCount, isUsable, name = GetQuestToolInfo(i, j)
			found = (name==text)
			if (found) then
				icon=iconFilename
				break
			end
		end
		if (found) then 
			break 
		end
	end
	return icon
end
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » GetItemLinkInfo - need help for LootDrop


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