Thread Tools Display Modes
12-12-16, 01:03 AM   #1
Tyrandir
A Defias Bandit
 
Tyrandir's Avatar
Join Date: Dec 2016
Posts: 3
Getting icon address from loot using GetLootInfo()

Hi there! I've been trying to get an icon address from a looted item using GetLootInfo() and compare the address to one I've specifically supplied as a variable for comparison. The full version of the code is attached, but this is the problem area:

Code:
	local lootIndex = GetNumLootItems()
	print("function call successful")
	if (lootIndex == 1) then
		
		local lootInfo = GetLootInfo()
		
		local fish1 = "Interface\\ICONS\\INV_misc_fish_06"
		local fish2 = "Interface\\ICONS\\INV_misc_fish_02"
		local fish3 = "Interface\\ICONS\\INV_misc_fish_19"
		
		print(lootInfo)
		--[[print("lootInfo[1] "..lootInfo[1])
		print("lootInfo[texture] "..lootInfo[texture])
		print("lootInfo.texture "..lootInfo.texture)]]
		print("testing, image address should be above")
		
		if(lootInfo == fish1) then
			print("success!")
		elseif(lootInfo == fish2) then
			print("success!")
		elseif(lootInfo == fish3) then
			print("success!")
		end
		
	end
I've been sitting in Moonglade fishing, so those are the icons I'm comparing against. It enters the function successfully, and prints out "table:" and then when looks to be a memory address, where I keep hoping the image path will be. I thought perhaps there was some issue with string conversion or something (as the API indicates it SHOULD be a string) which is why I was testing it against the fish paths, in case instead of an actual path it might be storing a pointer to the icon or something to that effect.

Since it keeps showing a table value I've tried a variety of ways to access the value that I am expecting -- I've left most of these attempts in but commented out so you'd be able to see what I'd tried already. (lootInfo["texture"] has also been tried and didn't work, though I hadn't really expected that one to.)

My guess is that I'm not getting the right value from GetLootInfo() since I'm new to Lua. Any suggestions would be appreciated.
Attached Files
File Type: lua main.lua (5.1 KB, 132 views)
  Reply With Quote
12-12-16, 07:13 AM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Texture returns are IDs instead of paths nowadays. You should probably check against item ID or something, though.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
12-12-16, 08:05 AM   #3
Tyrandir
A Defias Bandit
 
Tyrandir's Avatar
Join Date: Dec 2016
Posts: 3
Thank you! I tried to pull other values using that function and found them all to be nil beyond the first that is a memory address, so I poked around the API a bit more to see if I could find a substitute and tried out GetLootSlotInfo() which is working much better -- the number it is providing is able to be matched with itself successfully after I've printed it and entered it for recognition, but doesn't match the item ID on wowhead.

Is there a function that would return that value or a place I would be able to look up the values for the items I need that correspond with whatever ID I'm accessing? (Not a huge deal for this project since it's working with a small scope of possible items, but seems like something that would be good to know for future projects.)
  Reply With Quote
12-12-16, 03:46 PM   #4
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Tyrandir View Post
Is there a function that would return that value or a place I would be able to look up the values for the items I need that correspond with whatever ID I'm accessing?

If you for some reason want to look up the icon texture paths for FileDataIDs you can find them herehttp://www.wowinterface.com/forums/s...ad.php?t=53918

Edit: I'm a bit confused if you like Lombra said, just need the item IDs instead of icon textures/ids

Last edited by Ketho : 12-12-16 at 04:13 PM.
  Reply With Quote
12-12-16, 08:25 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Are you printing the actual texture object (which would give you the address in memory of the table for that object) or is that .texture field supposed to be the string which references the icon used?

If the first one, you need to call :GetTexture() on it.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-13-16, 05:51 AM   #6
Tyrandir
A Defias Bandit
 
Tyrandir's Avatar
Join Date: Dec 2016
Posts: 3
This project involves making decisions based on what color gem chips are looted when prospecting. Since they turn into colorless chips after looting, I wasn't sure whether their item IDs would differ from one another (Though thinking on it now, it's obvious they must be. :P) and when I was doing the planning, had assumed I would need to compare the icon images in some way. This is not the case, and the project is pretty much done now! Everything works, I'm just trying to figure out how to properly use saved variables so that the last gem chip you prospected from your last session can be passed back in when it starts back up.

I apologize for any confusion, I just started asking further questions because I was curious how the texture stuff DID work. I appreciate the links and mention of :GetTexture(), so thank you.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Getting icon address from loot using GetLootInfo()


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