-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.lua
156 lines (133 loc) · 4.04 KB
/
init.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
SpeedyMount = LibStub("AceAddon-3.0"):NewAddon("SpeedyMount", "AceConsole-3.0", "AceEvent-3.0");
local name, sm = ...;
local options = {
name = "SpeedyMount",
handler = SpeedyMount,
type = 'group',
args = {
gloves = {
type = "input",
name = "Gloves",
desc = "Name of your speed increasing gloves",
usage = "<item name>",
set = "SetGloves",
},
boots = {
type = "input",
name = "Boots",
desc = "Name of your speed increasing boots",
usage = "<item name>",
set = "SetBoots"
},
trinket = {
type = "input",
name = "Trinket",
desc = "Name of your speed increasing trinket",
usage = "<item name>",
set = "SetTrinket",
},
reset = {
type = "input",
name = "Reset",
desc = "Reset outfit to non-riging gear",
usage = "",
set = "Reset",
}
}
};
do
local locale = GetLocale();
local convert = { enGB = "enUS", esES = "esMX", itIT = "enUS" };
local gameLocale = convert[locale] or locale or "enUS";
function SpeedyMount:GetLocale()
return gameLocale;
end
end
function SpeedyMount:OnEnable()
-- Events
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("UNIT_AURA");
self:RegisterEvent("PLAYER_REGEN_ENABLED");
self:RegisterEvent("PLAYER_UNGHOST");
self:RegisterEvent("PLAYER_ALIVE");
-- Addon Loaded
self:Print("Type /sm for Options");
sm.HasMount();
end
function SpeedyMount:OnInitialize()
-- Register the Database
self.db = LibStub("AceDB-3.0"):New("SpeedyMountDB", defaults, true);
if SpeedyMount.db.profile.riding == nil then
SpeedyMount.db.profile.riding = {
gloves = { nil, 10 },
boots = { nil, 8 },
trinket = { nil, 14 }
};
end
if SpeedyMount.db.profile.normal == nil then
SpeedyMount.db.profile.normal = {
gloves = { nil, 10 },
boots = { nil, 8 },
trinket = { nil, 14 }
};
end
if SpeedyMount.db.profile.inRidingGear == nil then
SpeedyMount.db.profile.inRidingGear = false;
end
if SpeedyMount.db.profile.swapGearAfterCombat == nil then
SpeedyMount.db.profile.swapGearAfterCombat = false;
end
LibStub("AceConfig-3.0"):RegisterOptionsTable("SpeedyMount", options);
self:RegisterChatCommand("sm", "ChatCommand");
end
function SpeedyMount:DisplayMessage(item, name)
return print("|cff1683d1SpeedyMount|r: ", item, " was updated to ", name);
end
function SpeedyMount:ChatCommand(input)
if not input or input:trim() == "" then
print("|cff1683d1SpeedyMount|r Options:");
print(" /sm (gloves | boots | trinket) (item link | item name | item id)");
else
LibStub("AceConfigCmd-3.0"):HandleCommand("sm", "SpeedyMount", input);
end
end
function SpeedyMount:PLAYER_ENTERING_WORLD()
sm.HasMount();
end
function SpeedyMount:UNIT_AURA()
local inLockdown = InCombatLockdown();
if inLockdown then
if SpeedyMount.db.profile.inRidingGear then
SpeedyMount.db.profile.swapGearAfterCombat = true;
end
else
sm.HasMount();
end
end
function SpeedyMount:PLAYER_REGEN_ENABLED()
if SpeedyMount.db.profile.swapGearAfterCombat then
sm.HasMount();
SpeedyMount.db.profile.swapGearAfterCombat = false;
end
end
function SpeedyMount:PLAYER_UNGHOST()
sm.HasMount();
end
function SpeedyMount:PLAYER_ALIVE()
sm.HasMount();
end
--------------------------------------------------
--- Getters and Setters
--------------------------------------------------
function SpeedyMount:SetGloves(_, value)
sm.SetGloves(value);
end
function SpeedyMount:SetBoots(_, value)
sm.SetBoots(value);
end
function SpeedyMount:SetTrinket(_, value)
sm.SetTrinket(value);
end
function SpeedyMount:Reset()
sm.Reset();
end