Reply
Thread Tools Display Modes
Unread 12-01-12, 12:06 PM   #1
pedenspeed
Zombie
Join Date: Dec 2012
Posts: 3
pulling stats off an item

Hello all,

Is there any way to pull the number value for a stat off of an inspected item. For instance when I inspect an item, and I use Inspect.Item.Detail, will it give me a number for strength, or will it just say there is strength on it. Any assistance with this would be great. Thanks for your time.
pedenspeed is offline   Reply With Quote
Unread 12-01-12, 04:11 PM   #2
Baanano
Bomani Harbinger
AddOn Author - Click to view addons
Join Date: Mar 2012
Posts: 5
According to the Addon API documentation of Inspect.Item.Detail:

Code:
stats:  The base stats of this item. Members may include "block",  "critAttack", "critSpell", "deflect", "dexterity", "dodge", "endurance",  "energyMax", "energyRegen", "focus", "hit", "intelligence", "manaMax",  "manaRegen", "movement", "parry", "powerAttack", "powerMax",  "powerRegen", "powerSpell", "resistAir", "resistDeath", "resistEarth",  "resistFire", "resistLife", "resistWater", "stealth", "stealthDetect",  "strength", "wisdom", "xp", "valor", "toughness", and "vengeance".
For your strength example it would be:

Code:
local itemStrength = Inspect.Item.Detail(item).stats.strength
Or, to do it safely:

Code:
local itemDetail = Inspect.Item.Detail(item)
local itemStrength = itemDetail and itemDetail.stats and itemDetail.stats.strength or 0
Baanano is offline   Reply With Quote
Unread 12-02-12, 11:15 AM   #3
pedenspeed
Zombie
Join Date: Dec 2012
Posts: 3
well I copy and pasted the code as you suggested, but it only returns a value of 0, which is what I was getting before as well. Any other suggestions? Or is there just no way to get the value of a stat into a variable?

Last edited by pedenspeed : 12-02-12 at 11:18 AM.
pedenspeed is offline   Reply With Quote
Unread 12-02-12, 07:03 PM   #4
Baanano
Bomani Harbinger
AddOn Author - Click to view addons
Join Date: Mar 2012
Posts: 5
What are just using as value for the item variable?

Just tried this and it works for me:

Code:
local item = Utility.Item.Slot.Equipment("helmet")
local itemDetail = Inspect.Item.Detail(item)
local itemStrength = itemDetail and itemDetail.stats and itemDetail.stats.strength or 0
Baanano is offline   Reply With Quote
Unread 12-05-12, 11:33 AM   #5
pedenspeed
Zombie
Join Date: Dec 2012
Posts: 3
Quote:
Originally Posted by Baanano View Post
What are just using as value for the item variable?

Just tried this and it works for me:

Code:
local item = Utility.Item.Slot.Equipment("helmet")
local itemDetail = Inspect.Item.Detail(item)
local itemStrength = itemDetail and itemDetail.stats and itemDetail.stats.strength or 0
Well this seems to work. It seems that the utility that I am using is not what I want to use. Let me start over by explaining what it is I am trying to do. I want to make an addon, that will allow me to compare items using a value based off of the theory crafting weights assigned to each stat per class. So that when I mouse over the item I looted, or the loot window that is up, I can see a single value instead of trying to figure out if its better to have more strength or more attack power. So with that being said, I can't use Utility.Item.Slot.Equipment since its not a single item, and if I use Inspect.Item.Detail(item) that doesn't seem to return a value, or it gives me an error. Any ideas on this? Your help so far has been much appreciated.
pedenspeed is offline   Reply With Quote
Unread 01-11-13, 08:33 PM   #6
Bullarky
Zombie
 
Bullarky's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2013
Posts: 2
I think what you are looking for is the following event:

Event.Tooltip
this will trigger every time the tooltip is changed.

Once fired, you will need to use

Inspect.Tooltip
This will get the entire tooltip object. In this object there is a type property that will hold "item" or "itemtype" for you to key off of... others tooltip types are "unit", "buff", and "ability"

Then use the code posted to pass the item...

Example:

Code:
function scrapeTooltip()
	local ttType = ""
	local ttItem = nil
	
	ttType, ttItem = Inspect.Tooltip()
	
	if ttType == "item" then
		TTGetItem(ttItem)
	elseif ttType then
		print(string.format("Type: %s", ttType))
	end
end

function TTGetItem(itm)
	local itemDetail = Inspect.Item.Detail(itm)
	local itemStrength = itemDetail and itemDetail.stats and itemDetail.stats.strength or 0
	if itemStrength then print(string.format("Strength: %s", itemStrength)) end
end

table.insert(Event.Tooltip, {scrapeTooltip, "Tester", "Tester_Init"})

Last edited by Bullarky : 01-11-13 at 08:36 PM.
Bullarky is offline   Reply With Quote
Reply

Go BackRiftui » Developer Discussions » Lua Help » pulling stats off an item

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