-
Notifications
You must be signed in to change notification settings - Fork 1
/
Bags.lua
executable file
·90 lines (78 loc) · 2.68 KB
/
Bags.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
local addonName, ATOM = ...
local Module = ATOM:NewModule('Bags')
local frameHooked = {}
local enableGlow, updateBagItems
function Module:OnInitialize()
if not _G['Bagnon'] then
-- hooksecurefunc('ContainerFrame_Update', updateBagItems)
end
end
function enableGlow(self)
local item = C_Container.GetContainerItemInfo(self:GetParent():GetID(), self:GetID())
if item and item.quality > Enum.ItemQuality.Common then
self.NewItemTexture:SetAtlas(NEW_ITEM_ATLAS_BY_QUALITY[quality])
self.NewItemTexture:SetAlpha(.8)
self.NewItemTexture:Show()
end
end
function updateBagItems(frame)
local name = frame:GetName()
local itemButtonName, itemButton
for i = 1, frame.size, 1 do
itemButtonName = name .. 'Item' .. i
itemButton = _G[itemButtonName]
if not frameHooked[itemButtonName] then
frameHooked[itemButtonName] = true
itemButton:HookScript('OnEnter', enableGlow)
itemButton:HookScript('OnLeave', enableGlow)
end
enableGlow(itemButton)
end
end
function Module:DestroyItems()
if CursorHasItem() then
return
end
-- LuaFormatter off
local destroyItems = {
'Blue Qiraji Resonating Crystal',
'Book of the Ages',
'Charred Recipe',
'Condensed Jademist',
'Dew of Eternal Morning',
'Green Qiraji Resonating Crystal',
'Idol',
'Jewel of Maddening Whispers',
'Red Qiraji Resonating Crystal',
'Scarab',
'Singing Crystal',
'Strange Glowing Mushroom',
'Thorny Loop',
'Warped Warning Sign',
'Yellow Qiraji Resonating Crystal',
"Qiraji Lord's Insignia",
}
local protectedItems = {
['Korthian Armaments'] = true,
}
-- LuaFormatter on
for bagID = BACKPACK_CONTAINER, NUM_BAG_SLOTS do
for slot = 1, C_Container.GetContainerNumSlots(bagID) do
local itemLink = C_Container.GetContainerItemLink(bagID, slot) or ''
local itemName = string.match(itemLink, '|h%[([^%]]+)%]|h')
local item = C_Container.GetContainerItemInfo(bagID, slot)
-- check if item is an heirloom
if item and item.quality == 7 and not protectedItems[itemName] then
C_Container.PickupContainerItem(bagID, slot)
DeleteCursorItem()
end
-- check if item in on the destroy list
for _, destroyItemName in ipairs(destroyItems) do
if itemName == destroyItemName then
C_Container.PickupContainerItem(bagID, slot)
DeleteCursorItem()
end
end
end
end
end