@@ -7,11 +7,11 @@ color does not exist.
7
7
]]
8
8
local function GetClassColorByGUID (guid )
9
9
if guid and guid ~= " " then
10
- local _ , englishClass = GetPlayerInfoByGUID (guid )
11
- if englishClass then
12
- local classColorTable = RAID_CLASS_COLORS [englishClass ];
13
- if classColorTable then
14
- return Elephant :MakeTextHexColor (classColorTable .r , classColorTable .g , classColorTable .b )
10
+ local _ , english_class = GetPlayerInfoByGUID (guid )
11
+ if english_class then
12
+ local class_color_table = RAID_CLASS_COLORS [english_class ];
13
+ if class_color_table then
14
+ return Elephant :MakeTextHexColor (class_color_table .r , class_color_table .g , class_color_table .b )
15
15
end
16
16
end
17
17
end
@@ -25,24 +25,24 @@ integer for them.
25
25
26
26
Returns nil if a channel cannot be found.
27
27
]]
28
- local function getCIndexFromChannelName ( channelName )
29
- if channelName == " " then
28
+ local function GetChannelIndexFromChannelName ( channel_name )
29
+ if channel_name == " " then
30
30
return nil
31
31
end
32
32
33
- channelName = string.lower (channelName )
34
- local cIndex
35
- for k , v in pairs (Elephant .L [' generalchats' ]) do
36
- if (channelName == k ) or string.find (channelName , k .. " - " ) then
37
- cIndex = k
33
+ channel_name = string.lower (channel_name )
34
+ local channel_index
35
+ for general_chat_channel_name , _ in pairs (Elephant .L [' generalchats' ]) do
36
+ if (channel_name == general_chat_channel_name ) or string.find (channel_name , general_chat_channel_name .. " - " ) then
37
+ channel_index = general_chat_channel_name
38
38
break
39
39
end
40
40
end
41
- if cIndex == nil then
41
+ if channel_index == nil then
42
42
-- Custom channel name
43
- cIndex = channelName
43
+ channel_index = channel_name
44
44
end
45
- return cIndex
45
+ return channel_index
46
46
end
47
47
48
48
--[[
@@ -58,19 +58,19 @@ local function HandleMessage(prat_struct, event, ...)
58
58
end
59
59
60
60
-- Getting info from event args
61
- local message , sender , _ , _ , _ , flags , _ , _ , channelName , _ , _ , guid = ...
61
+ local message , sender , _ , _ , _ , flags , _ , _ , channel_name , _ , _ , guid = ...
62
62
if flags == " " then
63
63
flags = nil
64
64
end
65
65
66
66
-- Sometimes we need to log two messages for the price of one.
67
- local msg , msg2
67
+ local new_message_struct , new_message_struct_2
68
68
-- Channels
69
69
if event == " CHAT_MSG_CHANNEL" or event == " CHAT_MSG_CHANNEL_NOTICE" then
70
- cIndex = getCIndexFromChannelName ( channelName )
70
+ local channel_index = GetChannelIndexFromChannelName ( channel_name )
71
71
72
- -- cIndex == nil should never happen, but better to ignore than crash.
73
- if cIndex == nil or Elephant :IsFiltered (cIndex ) then return end
72
+ -- channel_index == nil should never happen, but better to ignore than crash.
73
+ if channel_index == nil or Elephant :IsFiltered (channel_index ) then return end
74
74
75
75
if event == " CHAT_MSG_CHANNEL" then
76
76
-- Fixing error where structure for channel does not exist
@@ -79,74 +79,74 @@ local function HandleMessage(prat_struct, event, ...)
79
79
-- event for that channel. In this case though, the client cannot be
80
80
-- displaying that log, so we don't have to update the buttons like
81
81
-- when a YOU_JOINED event happens.
82
- Elephant :InitCustomStructure ( cIndex , channelName )
83
- if not Elephant .dbpc .char .logs [cIndex ].enabled then
82
+ Elephant :MaybeInitCustomStructure ( channel_index , channel_name )
83
+ if not Elephant .dbpc .char .logs [channel_index ].enabled then
84
84
return
85
85
end
86
86
87
87
if prat_struct then
88
- msg = {
88
+ new_message_struct = {
89
89
[' time' ] = time (),
90
90
[' prat' ] = prat_struct .message ,
91
91
[' lineid' ] = prat_struct .line_id ,
92
92
}
93
93
else
94
- msg = {
94
+ new_message_struct = {
95
95
[' time' ] = time (),
96
96
[' arg1' ] = message ,
97
97
[' arg6' ] = flags ,
98
- [' arg9' ] = channelName ,
98
+ [' arg9' ] = channel_name ,
99
99
[' clColor' ] = GetClassColorByGUID (guid )
100
100
}
101
101
if sender ~= " " then
102
- msg [' arg2' ] = sender
102
+ new_message_struct [' arg2' ] = sender
103
103
end
104
104
end
105
- Elephant :CaptureNewMessage (msg , cIndex )
105
+ Elephant :CaptureNewMessage (new_message_struct , channel_index )
106
106
end
107
107
108
108
if event == " CHAT_MSG_CHANNEL_NOTICE" then
109
109
if message == " YOU_JOINED" or message == " YOU_CHANGED" then
110
- Elephant :InitCustomStructure ( cIndex , channelName )
111
- if not Elephant .dbpc .char .logs [cIndex ].enabled then
110
+ Elephant :MaybeInitCustomStructure ( channel_index , channel_name )
111
+ if not Elephant .dbpc .char .logs [channel_index ].enabled then
112
112
return
113
113
end
114
114
115
- Elephant :CaptureNewMessage ( { [' type' ] = " SYSTEM" , [' arg1' ] = Elephant .L [' customchat' ][' join' ] } , cIndex )
116
- if Elephant .dbpc .char .currentlogindex == cIndex then
115
+ Elephant :CaptureNewMessage ( { [' type' ] = " SYSTEM" , [' arg1' ] = Elephant .L [' customchat' ][' join' ] } , channel_index )
116
+ if Elephant .dbpc .char .currentlogindex == channel_index then
117
117
Elephant :UpdateCurrentLogButtons ()
118
118
end
119
119
end
120
120
if message == " YOU_LEFT" then
121
- if not Elephant .dbpc .char .logs [cIndex ] or Elephant .dbpc .char .logs [cIndex ].enabled then
121
+ if not Elephant .dbpc .char .logs [channel_index ] or Elephant .dbpc .char .logs [channel_index ].enabled then
122
122
return
123
123
end
124
124
125
- Elephant :CaptureNewMessage ( { [' type' ] = " SYSTEM" , [' arg1' ] = Elephant .L [' customchat' ][' leave' ] } , cIndex )
126
- Elephant :CaptureNewMessage ( { [' arg1' ] = " " } , cIndex )
127
- if Elephant .dbpc .char .currentlogindex == cIndex then
125
+ Elephant :CaptureNewMessage ( { [' type' ] = " SYSTEM" , [' arg1' ] = Elephant .L [' customchat' ][' leave' ] } , channel_index )
126
+ Elephant :CaptureNewMessage ( { [' arg1' ] = " " } , channel_index )
127
+ if Elephant .dbpc .char .currentlogindex == channel_index then
128
128
Elephant :UpdateCurrentLogButtons ()
129
129
Elephant :ForceCurrentLogDeleteButtonStatus (true )
130
130
end
131
131
end
132
132
end
133
- -- Not channel messages
134
133
else
134
+ -- Not channel messages
135
135
if prat_struct then
136
- msg = {
136
+ new_message_struct = {
137
137
[' time' ] = time (),
138
138
[' prat' ] = prat_struct .message ,
139
139
[' lineid' ] = prat_struct .line_id ,
140
140
[' type' ] = Elephant .db .profile .events [event ].type ,
141
141
}
142
142
else
143
- msg = {
143
+ new_message_struct = {
144
144
[' time' ] = time (),
145
145
[' type' ] = Elephant .db .profile .events [event ].type ,
146
146
[' arg1' ] = message ,
147
147
}
148
148
149
- if event == " CHAT_MSG_BATTLEGROUND" or
149
+ if event == " CHAT_MSG_BATTLEGROUND" or
150
150
event == " CHAT_MSG_BATTLEGROUND_LEADER" or
151
151
event == " CHAT_MSG_WHISPER" or
152
152
event == " CHAT_MSG_WHISPER_INFORM" or
@@ -172,12 +172,12 @@ local function HandleMessage(prat_struct, event, ...)
172
172
event == " CHAT_MSG_INSTANCE_CHAT" or
173
173
event == " CHAT_MSG_INSTANCE_CHAT_LEADER"
174
174
then
175
- msg .arg2 = sender
176
- msg .clColor = GetClassColorByGUID (guid )
175
+ new_message_struct .arg2 = sender
176
+ new_message_struct .clColor = GetClassColorByGUID (guid )
177
177
end
178
178
179
179
if event == " CHAT_MSG_WHISPER" then
180
- msg .arg6 = flags
180
+ new_message_struct .arg6 = flags
181
181
end
182
182
183
183
if event == " PARTY_LOOT_METHOD_CHANGED" then
@@ -195,43 +195,43 @@ local function HandleMessage(prat_struct, event, ...)
195
195
end
196
196
end
197
197
198
- msg2 = {
198
+ new_message_struct_2 = {
199
199
[' time' ] = time (),
200
200
[' type' ] = Elephant .db .profile .events [event ].type
201
201
}
202
202
203
203
-- Name of player may be unknown here, if interface
204
204
-- has just been loaded
205
205
if player == " Unknown" then
206
- msg2 .arg1 = " <" .. Elephant .L [' masterlooternameunknown' ] .. " >"
206
+ new_message_struct_2 .arg1 = " <" .. Elephant .L [' masterlooternameunknown' ] .. " >"
207
207
elseif player ~= Elephant .tempConf .masterlooter then
208
208
Elephant .tempConf .masterlooter = player
209
209
210
- msg2 .arg1 = format (Elephant .L [' masterlooterchanged' ], player )
210
+ new_message_struct_2 .arg1 = format (Elephant .L [' masterlooterchanged' ], player )
211
211
end
212
212
else
213
213
Elephant .tempConf .masterlooter = nil
214
214
end
215
215
216
216
if method ~= Elephant .tempConf .lootmethod then
217
217
Elephant .tempConf .lootmethod = method
218
- msg .arg1 = Elephant .L [' lootmethod' ][method ]
218
+ new_message_struct .arg1 = Elephant .L [' lootmethod' ][method ]
219
219
else
220
- -- Warning: msg2 might also be nil
221
- msg = msg2
222
- msg2 = nil
220
+ -- Warning: new_message_struct_2 might also be nil
221
+ new_message_struct = new_message_struct_2
222
+ new_message_struct_2 = nil
223
223
end
224
224
end
225
225
end
226
226
227
227
-- Finally, capture the message if it is not nil
228
- if msg ~= nil then
229
- local k
230
- for k in pairs (Elephant .db .profile .events [event ].channels ) do
231
- if Elephant .db .profile .events [event ].channels [k ] ~= 0 and Elephant .dbpc .char .logs [k ].enabled then
232
- Elephant :CaptureNewMessage (msg , k )
233
- if msg2 ~= nil then
234
- Elephant :CaptureNewMessage (msg2 , k )
228
+ if new_message_struct ~= nil then
229
+ local channel_index
230
+ for channel_index in pairs (Elephant .db .profile .events [event ].channels ) do
231
+ if Elephant .db .profile .events [event ].channels [channel_index ] ~= 0 and Elephant .dbpc .char .logs [channel_index ].enabled then
232
+ Elephant :CaptureNewMessage (new_message_struct , channel_index )
233
+ if new_message_struct_2 ~= nil then
234
+ Elephant :CaptureNewMessage (new_message_struct_2 , channel_index )
235
235
end
236
236
end
237
237
end
@@ -253,23 +253,23 @@ loaded.
253
253
function Elephant :RegisterEventsRefresh ()
254
254
Elephant :UnregisterAllEvents ()
255
255
256
- local event
256
+ local event_type
257
257
if Prat and Elephant .db .profile .prat then
258
258
Prat .RegisterChatEvent (Elephant , Prat .Events .POST_ADDMESSAGE )
259
259
260
260
-- Registering additional events not handled by Prat
261
- for event , v in pairs (Elephant .db .profile .events ) do
262
- if v .register_with_prat then
263
- Elephant :RegisterEvent (event , HandleMessage , nil )
261
+ for event_type , event_struct in pairs (Elephant .db .profile .events ) do
262
+ if event_struct .register_with_prat then
263
+ Elephant :RegisterEvent (event_type , HandleMessage , nil )
264
264
end
265
265
end
266
266
else
267
267
if not Prat and Elephant .db .profile .prat then
268
268
Elephant :Print (" |cffff0000" .. Elephant .L [' noprat' ] .. " |r" )
269
269
end
270
270
271
- for event , v in pairs (Elephant .db .profile .events ) do
272
- Elephant :RegisterEvent (event , HandleMessage , nil )
271
+ for event_type , event_struct in pairs (Elephant .db .profile .events ) do
272
+ Elephant :RegisterEvent (event_type , HandleMessage , nil )
273
273
end
274
274
end
275
275
end
0 commit comments