forked from kemayo/wow-bankstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto.lua
More file actions
81 lines (75 loc) · 2.27 KB
/
auto.lua
File metadata and controls
81 lines (75 loc) · 2.27 KB
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
local core = BankStack
local module = core:NewModule("Auto", "AceEvent-3.0")
local Debug = core.Debug
local issecretvalue = _G.issecretvalue or function() return false end
local db
function module:OnInitialize()
self.db = core.db_object:RegisterNamespace("Auto", {
profile = {
bank_opened = "none",
afk = "none",
},
})
db = self.db
if core.options then
core.options.plugins.auto = {
auto = {
type = "group",
name = "Auto",
inline = true,
get = function(info) return db.profile[info[#info]] end,
set = function(info, value) db.profile[info[#info]] = value end,
args = {
bank_opened = {
type = "select",
name = "Bank opened",
values = {
none = "Nothing",
sort_bags = "Sort Bags",
sort_bank = "Sort Bank",
sort_both = "Sort Bags and Bank",
stack_to_bank = "Stack to Bank",
stack_to_bags = "Stack to Bags",
compress_bags = "Compress Bags",
compress_bank = "Compress Bank",
compress_both = "Compress Bags and Bank",
},
},
afk = {
type = "select",
name = "Going AFK",
values = {
none = "Nothing",
sort_bags = "Sort Bags",
compress_bags = "Compress Bags",
},
},
},
},
}
end
self:RegisterEvent("PLAYER_FLAGS_CHANGED")
end
local actions = {
sort_bags = core.CommandDecorator(core.SortBags, 'bags'),
sort_bank = core.CommandDecorator(core.SortBags, 'bank'),
sort_both = core.CommandDecorator(core.SortBags, 'bank bags'),
stack_to_bags = core.CommandDecorator(core.StackSummary, 'bank bags'),
stack_to_bank = core.CommandDecorator(core.StackSummary, 'bags bank'),
compress_bags = core.CommandDecorator(core.Compress, 'bags'),
compress_bank = core.CommandDecorator(core.Compress, 'bank'),
compress_both = core.CommandDecorator(core.Compress, 'bags bank'),
}
core.RegisterCallback("Auto", "Bank_Open", function(callback)
if not actions[db.profile.bank_opened] then return end
actions[db.profile.bank_opened]()
end)
function module:PLAYER_FLAGS_CHANGED(event, unit)
if unit ~= "player" then return end
if not actions[db.profile.afk] then return end
local isAFK = UnitIsAFK(unit)
-- SecretInChatMessagingLockdown:
if issecretvalue(isAFK) then return end
if not isAFK then return end
actions[db.profile.afk]()
end