Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Jul 27, 2024. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddonSwitcher.lua
More file actions
Latest commit
95 lines (89 loc) · 2.83 KB
/
Copy pathAddonSwitcher.lua
File metadata and controls
95 lines (89 loc) · 2.83 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
local_G=getfenv(0)
localevent=CreateFrame("Frame")
event:RegisterEvent"ADDON_LOADED"
event:SetScript("OnEvent", function(self, event, addon)
ifaddon~="AddonSwitcher" thenreturnend
if(not_G.asDB) then
_G.asDB= {}
end
end)
localfunctionpr(text)
print("|cffabd473AddonSwitcher|r: "..text)
end
localfunctionprofileSave(profile_name)
localdba= {}
fori=1, GetNumAddOns(), 1do
localname, _, _, enabled=GetAddOnInfo(i)
dba[name] =enabledand"1" or"0"
end
_G.asDB[profile_name] =dba
pr("Profile '"..profile_name.."' saved.")
end
localfunctionprofileLoad(profile_name, do_reload)
localdba=_G.asDB[profile_name]
ifdba~=nilthen
forn, einpairs(dba) do
ife=="1" then
EnableAddOn(n)
elseife=="0" then
DisableAddOn(n)
else
pr("Unknown state "..e.." for addon "..n..", skipping.")
end
end
ifdo_reloadthen
ReloadUI()
else
pr("Profile '"..profile_name.."' loaded. Reload your UI (e.g. with '/reload') to apply...")
end
else
pr("Unknown profile '"..profile_name.."'!")
end
end
localfunctionprofileDelete(profile_name)
localdba=_G.asDB[profile_name]
ifdba~=nilthen
_G.asDB[profile_name] =nil
pr("Profile '"..profile_name.."' deleted.")
else
pr("Unknown profile '"..profile_name.."'! Check existing profiles with '/as list'.")
end
end
localfunctionlistProfiles()
ifnext(_G.asDB) then
localempty=true
forproname, prdatainpairs(_G.asDB) do
ifemptythen
pr("Profiles:")
empty=false
end
print("* "..proname)
end
ifemptythenpr("No profiles!") end
else
pr("No profiles!")
end
end
SLASH_ADDONSWITCHER1="/addonswitcher"
SLASH_ADDONSWITCHER2="/as"
SlashCmdList["ADDONSWITCHER"] =function(msg)
localcommand, profile=msg:match("^(%S*)%s*(.-)$")
command=string.lower(command)
ifcommand=="save" then
profileSave(profileor"default")
elseifcommand=="load" orcommand=="switch" then
profileLoad(profileor"default", command=="switch")
elseifcommand=="list" then
listProfiles()
elseifcommand=="delete" then
profileDelete(profileor"default")
else
pr("Drauer's Addon Switcher, available commands (you can use /as or /addonswitcher if you like):")
print("/as switch <profile name> - Enable (and disable) AddOns from named profile AND RELOAD UI. The 'default' profile is taken if not specified.")
print("/as load <profile name> - Enable (and disable) AddOns from named profile without reloading UI. The 'default' profile is taken if not specified.")
print("/as save <profile name> - Save currently enabled and disbled AddOns as profile. The 'default' profile is taken if not specified.")
print("/as delete <profile name> - Delete profile. The 'default' profile is taken if not specified.")
print("/as list - Lists available profiles.")
print("** WARNING ** Profile names are case-sensitive.")
end
end