Skip to content

Commit 531e229

Browse files
committed
improve /ag spec command to show weapons value, undeprecate IsPlayerSpell, and fix nil reference error when an item tooltip line's left text is nil
1 parent c04c106 commit 531e229

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

AutoGear.lua

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,25 @@ local shouldPrintHelp = false
5959
local maxPlayerLevel = GetMaxPlayerLevel and GetMaxPlayerLevel() or GetMaxLevelForExpansionLevel(GetExpansionLevel())
6060
local L = T.Localization
6161
local ContainerIDToInventoryID = ContainerIDToInventoryID or (C_Container and C_Container.ContainerIDToInventoryID)
62-
local GetContainerNumSlots = GetContainerNumSlots or (C_Container and C_Container.GetContainerNumSlots)
63-
local PickupContainerItem = PickupContainerItem or (C_Container and C_Container.PickupContainerItem)
6462
local GetContainerNumFreeSlots = GetContainerNumFreeSlots or (C_Container and C_Container.GetContainerNumFreeSlots)
65-
local GetItemInventorySlotInfo = GetItemInventorySlotInfo or (C_Item and C_Item.GetItemInventorySlotInfo)
63+
local GetContainerNumSlots = GetContainerNumSlots or (C_Container and C_Container.GetContainerNumSlots)
64+
local GetDetailedItemLevelInfo = (C_Item and C_Item.GetDetailedItemLevelInfo) or GetDetailedItemLevelInfo
6665
local GetItemCount = (C_Item and function(info, includeBank, includeUses, includeReagentBank, includeAccountBank)
6766
if info then
6867
return C_Item.GetItemCount(info, includeBank or false, includeUses or false, includeReagentBank or true, includeAccountBank or true)
6968
end
7069
end) or GetItemCount
71-
local GetItemSpell = GetItemSpell or (C_Item and C_Item.GetItemSpell)
72-
local GetDetailedItemLevelInfo = (C_Item and C_Item.GetDetailedItemLevelInfo) or GetDetailedItemLevelInfo
7370
local GetItemInfo = GetItemInfo or (C_Item and C_Item.GetItemInfo)
7471
local GetItemInfoInstant = GetItemInfoInstant or (C_Item and C_Item.GetItemInfoInstant)
75-
local GetNumTalentTabs = GetNumSpecializations or GetNumTalentTabs
76-
local GetSpecialization = GetSpecialization or (C_SpecializationInfo and C_SpecializationInfo.GetSpecialization)
77-
local GetSpecializationInfo = GetSpecializationInfo or (C_SpecializationInfo and C_SpecializationInfo.GetSpecializationInfo)
72+
local GetItemInventorySlotInfo = GetItemInventorySlotInfo or (C_Item and C_Item.GetItemInventorySlotInfo)
73+
local GetItemSpell = GetItemSpell or (C_Item and C_Item.GetItemSpell)
7874
local GetMouseFocus = GetMouseFocus or (GetMouseFoci and (function()
7975
local frames = GetMouseFoci()
8076
return frames and frames[1];
8177
end))
78+
local GetNumTalentTabs = GetNumSpecializations or GetNumTalentTabs
79+
local GetSpecialization = GetSpecialization or (C_SpecializationInfo and C_SpecializationInfo.GetSpecialization)
80+
local GetSpecializationInfo = GetSpecializationInfo or (C_SpecializationInfo and C_SpecializationInfo.GetSpecializationInfo)
8281
local InterfaceOptions_AddCategory = InterfaceOptions_AddCategory or function(frame, addOn, position)
8382
frame.OnCommit = frame.okay
8483
frame.OnDefault = frame.default
@@ -95,6 +94,8 @@ local InterfaceOptions_AddCategory = InterfaceOptions_AddCategory or function(fr
9594
end
9695
end
9796
local InterfaceOptionsFrame_OpenToCategory = InterfaceOptionsFrame_OpenToCategory or Settings.OpenToCategory
97+
local IsPlayerSpell = C_SpellBook and C_SpellBook.IsSpellKnown or IsPlayerSpell
98+
local PickupContainerItem = PickupContainerItem or (C_Container and C_Container.PickupContainerItem)
9899
AutoGearWouldRoll = "nil"
99100
AutoGearSomeItemDataIsMissing = nil
100101
AutoGearFirstEquippableBagSlot = ContainerIDToInventoryID(1) or 20
@@ -2285,7 +2286,7 @@ SlashCmdList["AutoGear"] = function(msg)
22852286
if usingPawn then
22862287
pawnScaleName, pawnScaleLocalizedName = AutoGearGetPawnScaleName()
22872288
end
2288-
AutoGearPrint("AutoGear: Looks like you are a"..(realSpec:find("^[AEIOUaeiou]") and "n " or " ")..RAID_CLASS_COLORS[realClass]:WrapTextInColorCode(realSpec.." "..localizedRealClass).."."..((usingPawn or (AutoGearDB.Override and ((realClassID ~= overrideClassID) or (realSpec ~= overrideSpec)))) and (" However, AutoGear is using "..(usingPawn and ("Pawn scale \""..PawnGetScaleColor(pawnScaleName)..(pawnScaleLocalizedName or pawnScaleName)..FONT_COLOR_CODE_CLOSE.."\"") or (RAID_CLASS_COLORS[overrideClass]:WrapTextInColorCode(overrideSpec.." "..localizedOverrideClass).." weights")).." for gear evaluation due to the \""..(usingPawn and "Use Pawn to evaluate upgrades" or "Override specialization").."\" option.") or ""), 0)
2289+
AutoGearPrint("AutoGear: Looks like you are a"..(realSpec:find("^[AEIOUaeiou]") and "n " or " ")..RAID_CLASS_COLORS[realClass]:WrapTextInColorCode(realSpec.." "..localizedRealClass).."."..((usingPawn or (AutoGearDB.Override and ((realClassID ~= overrideClassID) or (realSpec ~= overrideSpec)))) and (" However, AutoGear is using "..(usingPawn and ("Pawn scale \""..PawnGetScaleColor(pawnScaleName)..(pawnScaleLocalizedName or pawnScaleName)..FONT_COLOR_CODE_CLOSE.."\"") or (RAID_CLASS_COLORS[overrideClass]:WrapTextInColorCode(overrideSpec.." "..localizedOverrideClass).." weights")).." for gear evaluation due to the \""..(usingPawn and "Use Pawn to evaluate upgrades" or "Override specialization").."\" option.") or "").." AutoGear is using weapons value \""..weapons.."\" from \""..((AutoGearDB.Override and ((realClassID ~= overrideClassID) or (realSpec ~= overrideSpec))) and (RAID_CLASS_COLORS[overrideClass]:WrapTextInColorCode(overrideSpec.." "..localizedOverrideClass)) or (RAID_CLASS_COLORS[realClass]:WrapTextInColorCode(realSpec.." "..localizedRealClass))).."\" to determine which weapons are valid. CanDualWield() returns \""..(CanDualWield() and "true" or "false").."\".", 0)
22892290
elseif (param1 == "verbosity") or (param1 == "allowedverbosity") then
22902291
AutoGearSetAllowedVerbosity(param2)
22912292
elseif ((param1 == "setspec") or
@@ -3548,7 +3549,7 @@ function AutoGearReadItemInfo(inventoryID, lootRollID, container, slot, questRew
35483549
r, g, b = tooltipData.lines[i].leftColor:GetRGB()
35493550
end
35503551
if not textLeftText then
3551-
textLeftText = textLeft:GetText()
3552+
textLeftText = textLeft:GetText() or ""
35523553
end
35533554
local text = select(1,string.gsub(textLeftText:lower(),",",""))
35543555
if i==1 then

0 commit comments

Comments
 (0)