Skip to content

Commit

Permalink
Fix opening lockboxes with profession keys
Browse files Browse the repository at this point in the history
  • Loading branch information
p3lim committed Jul 24, 2024
1 parent f4d2c9d commit 2050e62
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions addon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ addon:HookTooltip(function(tooltip, item)
GameTooltip:AddLine(ERR_USE_LOCKED_WITH_SPELL_S:format(spellName), FACTION_RED_COLOR:GetRGB())
return
elseif numItemsRequired and C_Item.GetStackCount(item:GetItemLocation()) < numItemsRequired then
GameTooltip:AddLine(SPELL_FAILED_NEED_MORE_ITEMS:format(numItemsRequired, C_Item.GetItemName(item:GetItemLocation())), FACTION_RED_COLOR:GetRGB())
GameTooltip:AddLine(SPELL_FAILED_NEED_MORE_ITEMS:format(numItemsRequired, C_Item.GetItemNameByID(itemID)), FACTION_RED_COLOR:GetRGB())
return
else
return Molinari:ApplySpell(item, spellID, color)
end
end

local pickItemID
pickItemID, color = addon:IsOpenableProfession(itemID)
if pickItemID then
return Molinari:ApplyItem(item, pickItemID, color)
local key
key, color = addon:IsOpenableProfession(itemID)
if key then
return Molinari:ApplyItem(item, key, color)
end
end)

Expand Down Expand Up @@ -104,13 +104,13 @@ function Molinari:ApplySpell(item, spellID, color)
self:SetColor(color)
end

function Molinari:ApplyItem(item, color)
function Molinari:ApplyItem(item, key, color)
local location = item:GetItemLocation()
if location and location:IsBagAndSlot() then
local bagID, slotID = location:GetBagAndSlot()
self:SetAttribute('target-bag', bagID)
self:SetAttribute('target-slot', slotID)
self:SetAttribute('item', 'item:' .. item:GetItemID())
self:SetAttribute('item', 'item:' .. key)

self.itemID = item:GetItemID() -- for tooltips
self:Show()
Expand Down Expand Up @@ -199,7 +199,7 @@ Molinari:HookScript('OnEnter', function(self)
local spellName = (C_Spell.GetSpellName or GetSpellInfo)(self.spellID)
GameTooltip:AddLine((('\n'):split(NPEV2_CASTER_ABILITYINITIAL:gsub(' %%s ', '%s'))):format('|A:NPE_LeftClick:18:18|a', '|cff0090ff' .. spellName .. '|r'))
elseif self.itemID then
GameTooltip:AddLine(NPEV2_ABILITYINITIAL:format('|A:NPE_LeftClick:18:18|a', '|cff0090ff' .. C_Item.GetItemName(self.itemID) .. '|r'))
GameTooltip:AddLine(NPEV2_ABILITYINITIAL:format('|A:NPE_LeftClick:18:18|a', '|cff0090ff' .. C_Item.GetItemNameByID(self.itemID) .. '|r'))
end
end

Expand Down

0 comments on commit 2050e62

Please sign in to comment.