Riftui

Riftui (https://www.riftui.com/forums/index.php)
-   Lua Help (https://www.riftui.com/forums/forumdisplay.php?f=16)
-   -   pulling stats off an item (https://www.riftui.com/forums/showthread.php?t=324)

pedenspeed 12-01-12 12:06 PM

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.

Baanano 12-01-12 04:11 PM

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


pedenspeed 12-02-12 11:15 AM

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?

Baanano 12-02-12 07:03 PM

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


pedenspeed 12-05-12 11:33 AM

Quote:

Originally Posted by Baanano (Post 1056)
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.

Bullarky 01-11-13 08:33 PM

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"})



All times are GMT -6. The time now is 06:22 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2022 MMOUI