From d8539f81febcd795b0021365200dc4516d649464 Mon Sep 17 00:00:00 2001 From: Bunny67 Date: Sun, 8 Jul 2018 10:49:19 +0300 Subject: [PATCH] update bags --- !Compatibility/api/wowAPI.lua | 7 +++++++ ElvUI/Modules/Bags/Bags.lua | 6 +----- ElvUI/Modules/Bags/Sort.lua | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/!Compatibility/api/wowAPI.lua b/!Compatibility/api/wowAPI.lua index 898a1a7..d29bc2f 100644 --- a/!Compatibility/api/wowAPI.lua +++ b/!Compatibility/api/wowAPI.lua @@ -279,6 +279,13 @@ local bagTypes = { } function GetItemFamily(id) + if not id then return end + if type(id) == "table" or type(id) == "function" then return end + + if type(id) == "string" then + id = match(id, "item:(%d+)") + end + local _, _, _, _, _, itemType = GetItemInfo(id) return bagTypes[itemType] end diff --git a/ElvUI/Modules/Bags/Bags.lua b/ElvUI/Modules/Bags/Bags.lua index 2bc1284..09d88a4 100644 --- a/ElvUI/Modules/Bags/Bags.lua +++ b/ElvUI/Modules/Bags/Bags.lua @@ -449,11 +449,7 @@ function B:Layout(isBank) end f.Bags[bagID].numSlots = numSlots - local link = GetInventoryItemLink("player", ContainerIDToInventoryID(bagID)) - if link then - local _, _, id = strfind(link, "item:(%d+)") - f.Bags[bagID].type = GetItemFamily(id) - end + f.Bags[bagID].type = GetItemFamily(GetInventoryItemLink("player", ContainerIDToInventoryID(bagID))) --Hide unused slots for i = 1, MAX_CONTAINER_ITEMS do diff --git a/ElvUI/Modules/Bags/Sort.lua b/ElvUI/Modules/Bags/Sort.lua index 3853231..062b11f 100644 --- a/ElvUI/Modules/Bags/Sort.lua +++ b/ElvUI/Modules/Bags/Sort.lua @@ -371,7 +371,7 @@ function B:IsSpecialtyBag(bagID) local bag = GetInventoryItemLink("player", inventorySlot) if not bag then return false end - local family = GetItemFamily(match(bag, "item:(%d+)")) + local family = GetItemFamily(bag) if family == 0 or family == nil then return false end return family @@ -379,14 +379,14 @@ end function B:CanItemGoInBag(bag, slot, targetBag) local item = bagIDs[B:Encode_BagSlot(bag, slot)] - local itemFamily = GetItemFamily(match(item, "item:(%d+)")) + local itemFamily = GetItemFamily(item) if itemFamily then local equipSlot = select(8, GetItemInfo(item)) if equipSlot == "INVTYPE_BAG" then itemFamily = 1 end end - local bagFamily = GetItemFamily(match(targetBag, "item:(%d+)")) + local bagFamily = GetItemFamily(targetBag) if itemFamily then return (bagFamily == 0) or band(itemFamily, bagFamily) > 0 else