Hello everyone, I come here because I have a pretty annoying problem with the implementation of a function for my addon. I'm trying to determine the armor type that the user has dropped to understand if the user wants it or not (determined by an external variable). The goal is, with this function, to return either "plate", "mail", "leather" or "cloth" depending on the armor type the user dropped to, after, fetch from the variables the user specifications.
Code:
function ArmorType(item)
local _, _, _, _, _, class, subclass, _, equipSlot, _, _ = GetItemInfo(item)
local cloth = select(2, GetAuctionItemSubClasses(2))
local leather = select(3, GetAuctionItemSubClasses(2))
local mail = select(4, GetAuctionItemSubClasses(2))
local plate = select(5, GetAuctionItemSubClasses(2))
local returner = ""
if class ~= ARMOR then return nil end
if subclass ~= MISCELLANEOUS then
if subclass == plate then
returner = "plate"
elseif subclass == mail then
returner = "mail"
elseif subclass == leather then
returner = "leather"
elseif subclass == cloth then
returner = "cloth"
else returner = nil end
else
equipSlot = equipSlot:gsub("INVTYPE_", "")
returner = equipSlot == "TRINKET" and "trinkets" or
equipSlot == "NECK" and "necks" or
equipSlot == "FINGER" and "rings" or nil
end
return returner
end
As you might imagine the part of the fingers, necks and trinkets do work since those are non-localized strings contained in the equipSlot variable, but the armor types are not working since the subclass is a localized string of the armor type. I tried to look around in the
GlobalStrings.lua for something recalling these classes but with no luck and in the code you see I tried to work with the GetAuctionItemSubClasses which unfortunately it returns a number instead of a localized text (which I believe used to do before the pre-patch). Am I missing something obvious?
Sorry if my writings are convoluted or if I butchered some english, but as you may understand it's not my main language. Feel free to ask for better expanations