Skip to content

Commit

Permalink
Fixed loot counter
Browse files Browse the repository at this point in the history
  • Loading branch information
artscout committed Sep 13, 2022
1 parent eff74a7 commit 2ff82c3
Showing 1 changed file with 37 additions and 31 deletions.
68 changes: 37 additions & 31 deletions MSBTLoot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ local DisplayEvent = MikSBT.Animations.DisplayEvent

local IsClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC


-------------------------------------------------------------------------------
-- Constants.
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -127,33 +126,7 @@ local function HandleCurrency(parserEvent)
end


-- ****************************************************************************
-- Handles looted items.
-- ****************************************************************************
local function HandleItems(parserEvent)
-- Created items are buggy. Ignore them.
if (parserEvent.isCreate) then return end

-- Get information about the looted item.
local itemLink = parserEvent.itemLink
local itemName, _, itemQuality, _, _, itemType, _, _, _, itemTexture = GetItemInfo(itemLink)

-- Determine whether to show the event and ignore it if necessary.
local currentProfile = MSBTProfiles.currentProfile
local showEvent = true
if (currentProfile.qualityExclusions[itemQuality]) then showEvent = false end
if ((itemType == ITEM_TYPE_QUEST) and currentProfile.alwaysShowQuestItems) then showEvent = true end
if (currentProfile.itemExclusions[itemName]) then showEvent = false end
if (currentProfile.itemsAllowed[itemName]) then showEvent = true end
if (not showEvent) then return end

-- Format the item name according to its quality.
local qualityColor = ITEM_QUALITY_COLORS[itemQuality]
if (qualityPatterns[itemQuality]) then itemName = string_format(qualityPatterns[itemQuality], itemName) end

-- Get the number of items already existing in inventory and add the amount
-- looted to it if the item wasn't the result of a conjure.
local numLooted = parserEvent.amount or 1
local function loot_wait(itemLink, itemName, itemTexture, numLooted)
local numItems = 0
for bag = 0, NUM_BAG_SLOTS do
for slot = 1, GetContainerNumSlots(bag) do
Expand All @@ -170,10 +143,12 @@ local function HandleItems(parserEvent)

if (numItems == 0) then
numItems = numLooted
else
numItems = numItems + numLooted
end
local numTotal = numItems

local numTotal = numItems
if numItems <= 0 then
numTotal = numLooted
end

-- Format the event and display it.
local eventSettings = MSBTProfiles.currentProfile.events.NOTIFICATION_LOOT
Expand All @@ -184,6 +159,37 @@ local function HandleItems(parserEvent)
message = string_gsub(message, "%%t", numTotal)
DisplayEvent(eventSettings, message, itemTexture)
end

end

-- ****************************************************************************
-- Handles looted items.
-- ****************************************************************************
local function HandleItems(parserEvent)
-- Created items are buggy. Ignore them.
if (parserEvent.isCreate) then return end

-- Get information about the looted item.
local itemLink = parserEvent.itemLink
local itemName, _, itemQuality, _, _, itemType, _, _, _, itemTexture = GetItemInfo(itemLink)

-- Determine whether to show the event and ignore it if necessary.
local currentProfile = MSBTProfiles.currentProfile
local showEvent = true
if (currentProfile.qualityExclusions[itemQuality]) then showEvent = false end
if ((itemType == ITEM_TYPE_QUEST) and currentProfile.alwaysShowQuestItems) then showEvent = true end
if (currentProfile.itemExclusions[itemName]) then showEvent = false end
if (currentProfile.itemsAllowed[itemName]) then showEvent = true end
if (not showEvent) then return end

-- Format the item name according to its quality.
local qualityColor = ITEM_QUALITY_COLORS[itemQuality]
if (qualityPatterns[itemQuality]) then itemName = string_format(qualityPatterns[itemQuality], itemName) end

-- Get the number of items already existing in inventory and add the amount
-- looted to it if the item wasn't the result of a conjure.
local numLooted = parserEvent.amount or 1
C_Timer.After(0.5, function() loot_wait(itemLink, itemName, itemTexture, numLooted) end)
end


Expand Down

0 comments on commit 2ff82c3

Please sign in to comment.