Thread Tools Display Modes
03-18-24, 08:59 AM   #1
Codger
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2021
Posts: 30
Get gear item level question?

I'm working on an addon and I want to report the gear item level but I'm having trouble with
lua errors when I attempt it.

Here's what I'm doing:

local slotID = GetInventorySlotInfo(Headslot)
--this works, returning a 1

local ilvl = C_Item.GetCurrentItemLevel(slotID)
--This fails (*temporary) = "bad argument #1 to '?' (Usage: local currentItemLevel = C_Item.GetCurrentItemLevel(itemLocation))"

I obviously don't have the correct itemLocation but not sure how to find that.
I'm currently attempting to get the gear level when I open the mailbox but I could change this
to use the character screen, just not sure what event triggers when I open it.

I think I have a solution now. Here is what I'm doing...oops not quite - numbers don't match character screen??
Lua Code:
  1. local function getGearItemLvl(slotName)
  2.     print("getGearItemLvl("..slotName..")")
  3.     local slotId, texture, checkRelic = GetInventorySlotInfo(slotName)
  4.     local itemId = GetInventoryItemID("player", slotId)    
  5.     if (itemId ~= nil) then
  6.         local name, _, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemId)
  7.         print("getGearItemLvl("..slotName.." is "..iLevel..")")
  8.     end
  9. end

Last edited by Codger : 03-22-24 at 10:19 AM. Reason: I think I have a solution now
  Reply With Quote
03-18-24, 10:29 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
C_Item.GetCurrentItemLevel requires an ItemLocationMixin not slotID
Lua Code:
  1. local slotID = GetInventorySlotInfo(Headslot)
  2. local itemLocation = ItemLocation:CreateFromEquipmentSlot(slotID)
  3. local lvl = C_Item.GetCurrentItemLevel(itemLocation)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 03-18-24 at 10:32 AM.
  Reply With Quote
03-18-24, 10:52 AM   #3
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Oh, thanks for reminding me of that change. I haven't updated my item level addon in ages as I forgot that was added a while back.

Nevermind, I already updated to Dragonflight with no issues. Either I didn't need to use that function or I added it. But it did remind me of something I was envisioning adding to it at some point.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 03-18-24 at 10:54 AM.
  Reply With Quote
03-18-24, 10:56 AM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
You never know what 11 may bring to the table
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
03-18-24, 11:56 AM   #5
Codger
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2021
Posts: 30
Working but clunky

Thank you for the help.
It's working now... had a bit of trouble with empty slots and used a clunky workaround by looking at the texture. I'm sure there must be a better way to detect an empty slot but haven't found it yet.
Here's what I have now...

Lua Code:
  1. local function getGearItemLvl(slotName)
  2.     local lvl = 0
  3.     local slotID, texture, checkRelic = GetInventorySlotInfo(slotName)
  4.     if (slotID ~= nil) then
  5.         if (texture ~= 136525) then
  6.             local itemLocation = ItemLocation:CreateFromEquipmentSlot(slotID)
  7.             if (itemLocation ~= nil) then
  8.                 lvl = C_Item.GetCurrentItemLevel(itemLocation)
  9.             end
  10.         end    
  11.     end
  12.     --print("getGearItemLvl("..slotName..") " .. "  slotID: " .. slotID .. "  itemlevel: " .. lvl)
  13.     return format("%s", lvl)
  14. end

Last edited by Codger : 03-22-24 at 10:20 AM.
  Reply With Quote
03-18-24, 12:06 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
C_Item.DoesItemExist
Lua Code:
  1. local slotID = GetInventorySlotInfo(Headslot)
  2. local itemLocation = ItemLocation:CreateFromEquipmentSlot(slotID)
  3. if C_Item.DoesItemExist(itemLocation) then
  4.     local lvl = C_Item.GetCurrentItemLevel(itemLocation)
  5.     -- ...
  6. end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
03-18-24, 12:42 PM   #7
Codger
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2021
Posts: 30
Working great now

Thank you for your help!!
It's working the way I want now.

Lua Code:
  1. local function getGearItemLvl(slotName)
  2.     local lvl = 0
  3.     if (slotName ~= nil) then
  4.         local slotID, texture, checkRelic = GetInventorySlotInfo(slotName)
  5.         --print("getGearItemLvl    " .. slotID .. "     " .. texture .. "     " .. tostring(checkRelic))
  6.         if (slotID ~= nil) then
  7.             local itemLocation = ItemLocation:CreateFromEquipmentSlot(slotID)
  8.             if C_Item.DoesItemExist(itemLocation) then
  9.                 lvl = C_Item.GetCurrentItemLevel(itemLocation)
  10.             end
  11.         end
  12.     end
  13.     --print("getGearItemLvl("..slotName..") " .. "  slotID: " .. slotID .. "  itemlevel: " .. lvl)
  14.     return format("%s", lvl)
  15. end

For anyone that needs this the slotName is one of "HeadSlot", "NeckSlot", "ShoulderSlot", "BackSlot"...

Last edited by Codger : 03-22-24 at 10:20 AM.
  Reply With Quote
03-18-24, 01:00 PM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
Originally Posted by Codger View Post
For anyone that needs this the slotName is one of "HeadSlot", "NeckSlot", "ShoulderSlot", "BackSlot"...
For completeness: List of Slot IDs
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Get gear item level question?


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