Thread Tools Display Modes
05-04-14, 03:36 PM   #1
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Problem with GetItemQualityColor

Hi everyone,

I have a bug which I cannot seem to fix or figure out what is causing it. I have this code:

Lua Code:
  1. local function updateIcons()
  2.     if not PaperDollFrame:IsShown() then return end
  3.    
  4.     for i, slot in next, slots do
  5.         if i == 18 then i = 19 end
  6.         local link = GetInventoryItemLink("player", i)
  7.         local slotName = _G["Character"..slot.."Slot"]
  8.         local iconBorder = _G["mui_" .. "Character" .. slot .. "Slot"]         
  9.        
  10.         if link then
  11.             slotName.icon:SetAlpha(1)
  12.             local r, g, b, _ = GetItemQualityColor(select(3, GetItemInfo(link)))
  13.             iconBorder:SetBackdropBorderColor(r, g, b, 1)
  14.             iconBorder:SetBackdropColor(r,g,b,0.2)         
  15.         end
  16.     end
  17. end

running with this:
Lua Code:
  1. PaperDollFrame:HookScript("OnShow", updateIcons)
  2.     ef:RegisterEvent("UNIT_INVENTORY_CHANGED")
  3.     ef:SetScript("OnEvent", updateIcons)

in a PLAYER_LOGIN event. However this line:
Lua Code:
  1. local r, g, b, _ = GetItemQualityColor(select(3, GetItemInfo(link)))

shows this lua error each time I login:

Code:
Message: Interface\AddOns\MayronUI_Core\Skinning.lua:174: Usage: GetItemQualityColor(index)
Time: 05/04/14 22:10:48
Count: 15
Stack: [C]: ?
[C]: in function `GetItemQualityColor'
Interface\AddOns\MayronUI_Core\Skinning.lua:174: in function <Interface\AddOns\MayronUI_Core\Skinning.lua:163>

Locals:
It is just to get item icons fro mthe character frame and color the border depending on the items rarity value. I am not sure why this is happening because the player has logged in and it does actually work, but I get the error saying I'm using it incorrectly? I'm not sure and hopefully the code makes sense to know what I am trying to do. If anyone has any advice or a fix for me then that would be brilliant but if you need extra information let me know. Thanks in advance guys!


Usage: GetItemQualityColor(index)
  Reply With Quote
05-04-14, 04:58 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Either the link you get is bad, or GetItemInfo doesn't return stuff still, I reckon.

There seems to be a function GetInventoryItemQuality you can use instead.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
05-04-14, 05:01 PM   #3
Malakahh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 30
According to this: http://wowpedia.org/API_GetItemInfo
If you have not seen (I imagine this means your client have not yet made a call to GetItemInfo on some level, either through blizz code or otherwise) the item before in the current session, this function will return nil and asynchronously query the item from the server, which would break your current code.
I think a workaround would then be to, on PLAYER_ENTERING_WORLD, loop through all equipped items and call GetItemInfo() in order to query the server so that you now have "seen" the item, so that they are ready for when your OnShow is called.

EDIT:
Lombra's solution seems to be designed for your exact purpose, go with that.

Last edited by Malakahh : 05-04-14 at 05:05 PM.
  Reply With Quote
05-05-14, 09:05 AM   #4
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Thanks guys, I am not sure how I overlooked that method. Will try it tonight
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Problem with GetItemQualityColor


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