Thread Tools Display Modes
12-08-19, 05:35 PM   #1
Finalcast
A Kobold Labourer
Join Date: Dec 2019
Posts: 1
GetItemStats empty response (WOW Classic)

Hey,
I am just trying to learn a bit about WoW addons and while doing some tests I ran across the following
If I iterate over the items my character is wearing and get their links with:
link = GetInventoryItemLink("player", i)
and then I call:
GetItemStats(link)
I get the stats of *most* of my items but a few, it is not random, its always the same items. In this particular case my cape, my legs and a ring. If I switch the ring flor ring1 slot to ring2 slot, still I can not get the stats for the ring.
Interestingly the two items (besides the ring) I can not get the stats for are "of the eagle" items that sounds to me like templates for more or less randomly generated items.
So my questions are:
a) is it possible that GetItemStats is not really that reliable and some calls to certain items will always fail? For instance these "of the eagle" items, like if GetItemStats might be looking into a itemId table that does not contain these sort of randomly created items?
b) any way to deal with this other than falling back to tooltip scanning? (which is what I am doing now but I really hate having to have a fallback mechanism for a function provided by the api)


other minor issues I ran across playing with GetItemStats
ITEM_MOD_SPELL_POWER_SHORT
ITEM_MOD_POWER_REGENX_SHORT
and the like are always off by one (!)

and apparently there is no way to tell magic school damage in bonus I always get ITEM_MOD_SPELL_DAMAGE_DONE_SHORT
:S

Thanks

EDIT: as a matter of fact I've just checked the ring I was mentioning in the post and it is in fact a random enchantment ring "Seleniun loop of intellect" https://classic.wowhead.com/item=11990/selenium-loop

Last edited by Finalcast : 12-08-19 at 05:39 PM. Reason: checked the ring
  Reply With Quote
12-25-19, 11:35 PM   #2
Roeshambo
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jul 2019
Posts: 5
I've always found the easiest way to get stats for an item is using tooltips. You can create a tooltip but never display it, simply pushing the item link to it in a function is sufficient. You can also obtain spell damage type with the text just using patterns.

Code:
local scantip = CreateFrame("GameTooltip", "MyScanningTooltip", nil, "GameTooltipTemplate")
scantip:SetOwner(UIParent, "ANCHOR_NONE")

local function MyGetItemStats(link)
   scantip:SetHyperlink(link)
   for i=2, scantip:NumLines() do   -- can skip first line since it's just the item name.. or not. up to you
       local text = _G["MyScanningTooltipTextLeft"..i]:GetText())
       -- do stuff with text
   end
end
You can get a better idea as to what it's doing by mousing over an item in game and using:
/script for i=1, GameTooltip:NumLines() do print(_G["GameTooltipTextLeft"..i]:GetText()) end

Hopefully I'm getting the premise of your intent correct 0_o.

Last edited by Roeshambo : 12-25-19 at 11:38 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » GetItemStats empty response (WOW Classic)

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