View Single Post
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