Back to Home

ESO Lua File v100030

ingame/chatsystem/chatdata.lua

[◄ back to folders ]
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
local SimpleEventToCategoryMappings = {
    [EVENT_BROADCAST] = CHAT_CATEGORY_SYSTEM,
    [EVENT_FRIEND_PLAYER_STATUS_CHANGED] = CHAT_CATEGORY_SYSTEM,
    [EVENT_IGNORE_ADDED] = CHAT_CATEGORY_SYSTEM,
    [EVENT_IGNORE_REMOVED] = CHAT_CATEGORY_SYSTEM,
    [EVENT_GROUP_MEMBER_JOINED] = CHAT_CATEGORY_SYSTEM,
    [EVENT_GROUP_MEMBER_LEFT] = CHAT_CATEGORY_SYSTEM,
    [EVENT_GROUP_TYPE_CHANGED] = CHAT_CATEGORY_SYSTEM,
    [EVENT_GROUP_INVITE_RESPONSE] = CHAT_CATEGORY_SYSTEM,
    [EVENT_SOCIAL_ERROR] = CHAT_CATEGORY_SYSTEM,
    [EVENT_STUCK_ERROR_ON_COOLDOWN] = CHAT_CATEGORY_SYSTEM,
    [EVENT_STUCK_ERROR_ALREADY_IN_PROGRESS] = CHAT_CATEGORY_SYSTEM,
    [EVENT_STUCK_ERROR_IN_COMBAT] = CHAT_CATEGORY_SYSTEM,
    [EVENT_STUCK_ERROR_INVALID_LOCATION] = CHAT_CATEGORY_SYSTEM,
    [EVENT_TRIAL_FEATURE_RESTRICTED] = CHAT_CATEGORY_SYSTEM,
    [EVENT_BATTLEGROUND_INACTIVITY_WARNING] = CHAT_CATEGORY_SYSTEM,
}
local MultiLevelEventToCategoryMappings = {
    [EVENT_CHAT_MESSAGE_CHANNEL] = {
        [CHAT_CHANNEL_SAY] = GetChannelCategoryFromChannel(CHAT_CHANNEL_SAY),
        [CHAT_CHANNEL_YELL] = GetChannelCategoryFromChannel(CHAT_CHANNEL_YELL),
        [CHAT_CHANNEL_ZONE] = GetChannelCategoryFromChannel(CHAT_CHANNEL_ZONE),
        [CHAT_CHANNEL_ZONE_LANGUAGE_1] = GetChannelCategoryFromChannel(CHAT_CHANNEL_ZONE_LANGUAGE_1),
        [CHAT_CHANNEL_ZONE_LANGUAGE_2] = GetChannelCategoryFromChannel(CHAT_CHANNEL_ZONE_LANGUAGE_2),
        [CHAT_CHANNEL_ZONE_LANGUAGE_3] = GetChannelCategoryFromChannel(CHAT_CHANNEL_ZONE_LANGUAGE_3),
        [CHAT_CHANNEL_ZONE_LANGUAGE_4] = GetChannelCategoryFromChannel(CHAT_CHANNEL_ZONE_LANGUAGE_4),
        [CHAT_CHANNEL_WHISPER] = GetChannelCategoryFromChannel(CHAT_CHANNEL_WHISPER),
        [CHAT_CHANNEL_WHISPER_SENT] = GetChannelCategoryFromChannel(CHAT_CHANNEL_WHISPER_SENT),
        [CHAT_CHANNEL_PARTY] = GetChannelCategoryFromChannel(CHAT_CHANNEL_PARTY),
        [CHAT_CHANNEL_EMOTE] = GetChannelCategoryFromChannel(CHAT_CHANNEL_EMOTE),
        [CHAT_CHANNEL_SYSTEM] = GetChannelCategoryFromChannel(CHAT_CHANNEL_SYSTEM),
        [CHAT_CHANNEL_GUILD_1] = GetChannelCategoryFromChannel(CHAT_CHANNEL_GUILD_1),
        [CHAT_CHANNEL_GUILD_2] = GetChannelCategoryFromChannel(CHAT_CHANNEL_GUILD_2),
        [CHAT_CHANNEL_GUILD_3] = GetChannelCategoryFromChannel(CHAT_CHANNEL_GUILD_3),
        [CHAT_CHANNEL_GUILD_4] = GetChannelCategoryFromChannel(CHAT_CHANNEL_GUILD_4),
        [CHAT_CHANNEL_GUILD_5] = GetChannelCategoryFromChannel(CHAT_CHANNEL_GUILD_5),
        [CHAT_CHANNEL_OFFICER_1] = GetChannelCategoryFromChannel(CHAT_CHANNEL_OFFICER_1),
        [CHAT_CHANNEL_OFFICER_2] = GetChannelCategoryFromChannel(CHAT_CHANNEL_OFFICER_2),
        [CHAT_CHANNEL_OFFICER_3] = GetChannelCategoryFromChannel(CHAT_CHANNEL_OFFICER_3),
        [CHAT_CHANNEL_OFFICER_4] = GetChannelCategoryFromChannel(CHAT_CHANNEL_OFFICER_4),
        [CHAT_CHANNEL_OFFICER_5] = GetChannelCategoryFromChannel(CHAT_CHANNEL_OFFICER_5),
        [CHAT_CHANNEL_MONSTER_SAY] = GetChannelCategoryFromChannel(CHAT_CHANNEL_MONSTER_SAY),
        [CHAT_CHANNEL_MONSTER_YELL] = GetChannelCategoryFromChannel(CHAT_CHANNEL_MONSTER_YELL),
        [CHAT_CHANNEL_MONSTER_WHISPER] = GetChannelCategoryFromChannel(CHAT_CHANNEL_MONSTER_WHISPER),
        [CHAT_CHANNEL_MONSTER_EMOTE] = GetChannelCategoryFromChannel(CHAT_CHANNEL_MONSTER_EMOTE),
    },
}
local TrialEventMappings = {
    [TRIAL_RESTRICTION_CANNOT_ZONE_YELL] = true,
    [TRIAL_RESTRICTION_CANNOT_WHISPER] = true,
    [TRIAL_RESTRICTION_WHISPER_FRIENDS_ONLY] = true,
}
local function GetGuildChannelErrorFunction(guildIndex)
    return function()
        if GetNumGuilds() < guildIndex then
            return zo_strformat(SI_CANT_GUILD_CHAT_NOT_IN_GUILD, guildIndex)
        else
            local guildId = GetGuildId(guildIndex)
            return zo_strformat(SI_CANT_GUILD_CHAT_NO_PERMISSION, GetGuildName(guildId))
        end
    end
end
local function GetOfficerChannelErrorFunction(guildIndex)
    return function()
        if GetNumGuilds() < guildIndex then
            return zo_strformat(SI_CANT_GUILD_CHAT_NOT_IN_GUILD, guildIndex)
        else
            local guildId = GetGuildId(guildIndex)
            return zo_strformat(SI_CANT_OFFICER_CHAT_NO_PERMISSION, GetGuildName(guildId))
        end
    end
end
local ChannelInfo =
{
    [CHAT_CHANNEL_SAY] = {
        format = SI_CHAT_MESSAGE_SAY,
        name = GetString(SI_CHAT_CHANNEL_NAME_SAY),
        playerLinkable = true,
        channelLinkable = false,
        supportCSIcon = true,
        switches = GetString(SI_CHANNEL_SWITCH_SAY),
    },
    [CHAT_CHANNEL_YELL] =
    {
        format = SI_CHAT_MESSAGE_YELL,
        name = GetString(SI_CHAT_CHANNEL_NAME_YELL),
        playerLinkable = true,
        channelLinkable = false,
        supportCSIcon = true,
        switches = GetString(SI_CHANNEL_SWITCH_YELL)
    },
    [CHAT_CHANNEL_ZONE] =
    {
        format = SI_CHAT_MESSAGE_ZONE,
        name = GetString(SI_CHAT_CHANNEL_NAME_ZONE),
        playerLinkable = true,
        channelLinkable = false,
        supportCSIcon = true,
        switches = GetString(SI_CHANNEL_SWITCH_ZONE)
    },
    [CHAT_CHANNEL_PARTY] =
    {
        format = SI_CHAT_MESSAGE_PARTY,
        name = GetString(SI_CHAT_CHANNEL_NAME_PARTY),
        playerLinkable = true,
        channelLinkable = true,
        supportCSIcon = true,
        switches = GetString(SI_CHANNEL_SWITCH_PARTY),
        requires = function()
            return IsUnitGrouped("player")
        end,
        deferRequirement = true,
        requirementErrorMessage = GetString(SI_GROUP_NOTIFICATION_YOU_ARE_NOT_IN_A_GROUP)
    },
    [CHAT_CHANNEL_WHISPER] =
    {
        format = SI_CHAT_MESSAGE_WHISPER,
        name = GetString(SI_CHAT_CHANNEL_NAME_WHISPER),
        playerLinkable = true,
        channelLinkable = false,
        supportCSIcon = true,
        switches = GetString(SI_CHANNEL_SWITCH_WHISPER),
        target = true,
        saveTarget = CHAT_CHANNEL_WHISPER,
        targetSwitches = GetString(SI_CHANNEL_SWITCH_WHISPER_REPLY),
    },
    [CHAT_CHANNEL_WHISPER_SENT] =
    {
        format = SI_CHAT_MESSAGE_WHISPER_SENT,
        playerLinkable = true,
        channelLinkable = false,
        supportCSIcon = true,
    },
    [CHAT_CHANNEL_EMOTE] =
    {
        format = SI_CHAT_EMOTE,
        name = GetString(SI_CHAT_CHANNEL_NAME_EMOTE),
        playerLinkable = true,
        channelLinkable = false,
        switches = GetString(SI_CHANNEL_SWITCH_EMOTE),
    },
    [CHAT_CHANNEL_MONSTER_SAY] =
    {
        format = SI_CHAT_MONSTER_MESSAGE_SAY,
        playerLinkable = false,
        channelLinkable = false,
        formatMessage = true,
    },
    [CHAT_CHANNEL_MONSTER_YELL] =
    {
        format = SI_CHAT_MONSTER_MESSAGE_YELL,
        playerLinkable = false,
        channelLinkable = false,
        formatMessage = true,
    },
    [CHAT_CHANNEL_MONSTER_WHISPER] =
    {
        format = SI_CHAT_MONSTER_MESSAGE_WHISPER,
        playerLinkable = false,
        channelLinkable = false,
        formatMessage = true,
    },
    [CHAT_CHANNEL_MONSTER_EMOTE] =
    {
        format = SI_CHAT_MONSTER_EMOTE,
        playerLinkable = false,
        channelLinkable = false,
        formatMessage = true,
    },
    [CHAT_CHANNEL_SYSTEM] =
    {
        format = SI_CHAT_MESSAGE_SYSTEM,
        playerLinkable = false,
        channelLinkable = false,
    },
    [CHAT_CHANNEL_GUILD_1] =
    {
        format = SI_CHAT_MESSAGE_GUILD,
        dynamicName = true,
        playerLinkable = true,
        channelLinkable = true,
        switches = GetString(SI_CHANNEL_SWITCH_GUILD_1),
        requires = CanWriteGuildChannel,
        deferRequirement = true,
    },
    [CHAT_CHANNEL_GUILD_2] =
    {
        format = SI_CHAT_MESSAGE_GUILD,
        dynamicName = true,
        playerLinkable = true,
        channelLinkable = true,
        switches = GetString(SI_CHANNEL_SWITCH_GUILD_2),
        requires = CanWriteGuildChannel,
        deferRequirement = true,
    },
    [CHAT_CHANNEL_GUILD_3] =
    {
        format = SI_CHAT_MESSAGE_GUILD,
        dynamicName = true,
        playerLinkable = true,
        channelLinkable = true,
        switches = GetString(SI_CHANNEL_SWITCH_GUILD_3),
        requires = CanWriteGuildChannel,
        deferRequirement = true,
    },
    [CHAT_CHANNEL_GUILD_4] =
    {
        format = SI_CHAT_MESSAGE_GUILD,
        dynamicName = true,
        playerLinkable = true,
        channelLinkable = true,
        switches = GetString(SI_CHANNEL_SWITCH_GUILD_4),
        requires = CanWriteGuildChannel,
        deferRequirement = true,
    },
    [CHAT_CHANNEL_GUILD_5] =
    {
        format = SI_CHAT_MESSAGE_GUILD,
        dynamicName = true,
        playerLinkable = true,
        channelLinkable = true,
        switches = GetString(SI_CHANNEL_SWITCH_GUILD_5),
        requires = CanWriteGuildChannel,
        deferRequirement = true,
    },
    [CHAT_CHANNEL_OFFICER_1] =
    {
        format = SI_CHAT_MESSAGE_GUILD,
        dynamicName = true,
        playerLinkable = true,
        channelLinkable = true,
        switches = GetString(SI_CHANNEL_SWITCH_OFFICER_1),
        requires = CanWriteGuildChannel,
        deferRequirement = true,
    },
    [CHAT_CHANNEL_OFFICER_2] =
    {
        format = SI_CHAT_MESSAGE_GUILD,
        dynamicName = true,
        playerLinkable = true,
        channelLinkable = true,
        switches = GetString(SI_CHANNEL_SWITCH_OFFICER_2),
        requires = CanWriteGuildChannel,
        deferRequirement = true,
    },
    [CHAT_CHANNEL_OFFICER_3] =
    {
        format = SI_CHAT_MESSAGE_GUILD,
        dynamicName = true,
        playerLinkable = true,
        channelLinkable = true,
        switches = GetString(SI_CHANNEL_SWITCH_OFFICER_3),
        requires = CanWriteGuildChannel,
        deferRequirement = true,
    },
    [CHAT_CHANNEL_OFFICER_4] =
    {
        format = SI_CHAT_MESSAGE_GUILD,
        dynamicName = true,
        playerLinkable = true,
        channelLinkable = true,
        switches = GetString(SI_CHANNEL_SWITCH_OFFICER_4),
        requires = CanWriteGuildChannel,
        deferRequirement = true,
    },
    [CHAT_CHANNEL_OFFICER_5] =
    {
        format = SI_CHAT_MESSAGE_GUILD,
        dynamicName = true,
        playerLinkable = true,
        channelLinkable = true,
        switches = GetString(SI_CHANNEL_SWITCH_OFFICER_5),
        requires = CanWriteGuildChannel,
        deferRequirement = true,
    },
}
--TODO: Allow these in console when we implement tabs and filters
if not IsConsoleUI() then
    ChannelInfo[CHAT_CHANNEL_ZONE_LANGUAGE_1] =
    {
        format = SI_CHAT_MESSAGE_ZONE_ENGLISH,
        name = GetString(SI_CHAT_CHANNEL_NAME_ZONE_ENGLISH),
        playerLinkable = true,
        channelLinkable = false,
        supportCSIcon = true,
        switches = GetString(SI_CHANNEL_SWITCH_ZONE_ENGLISH)
    }
    ChannelInfo[CHAT_CHANNEL_ZONE_LANGUAGE_2] =
    {
        format = SI_CHAT_MESSAGE_ZONE_FRENCH,
        name = GetString(SI_CHAT_CHANNEL_NAME_ZONE_FRENCH),
        playerLinkable = true,
        channelLinkable = false,
        supportCSIcon = true,
        switches = GetString(SI_CHANNEL_SWITCH_ZONE_FRENCH)
    }
    ChannelInfo[CHAT_CHANNEL_ZONE_LANGUAGE_3] =
    {
        format = SI_CHAT_MESSAGE_ZONE_GERMAN,
        name = GetString(SI_CHAT_CHANNEL_NAME_ZONE_GERMAN),
        playerLinkable = true,
        channelLinkable = false,
        supportCSIcon = true,
        switches = GetString(SI_CHANNEL_SWITCH_ZONE_GERMAN)
    }
    ChannelInfo[CHAT_CHANNEL_ZONE_LANGUAGE_4] =
    {
        format = SI_CHAT_MESSAGE_ZONE_JAPANESE,
        name = GetString(SI_CHAT_CHANNEL_NAME_ZONE_JAPANESE),
        playerLinkable = true,
        channelLinkable = false,
        supportCSIcon = true,
        switches = GetString(SI_CHANNEL_SWITCH_ZONE_JAPANESE)
    }
end
-- Build switch lookup table
-- A switch is a string, eg "/zone", which you can start your chat message with to make sure it goes to a specific channel.
-- This lookup table has two kinds of entries in it:
-- * switch string -> channel data.
-- This is used to pick a channel based on the player's message and switch string.
-- * channel ID -> switch string.
-- This is used to enumerate what kinds of channels are available and what switch string you can use to refer to them.
-- Each channel can have multiple switches, in which case only the first switch string is used.
local g_switchLookup = {}
for channelId, data in pairs(ChannelInfo) do
    data.id = channelId
    if data.switches then
        for switchArg in data.switches:gmatch("%S+") do
            switchArg = switchArg:lower()
            g_switchLookup[switchArg] = data
            if not g_switchLookup[channelId] then
                g_switchLookup[channelId] = switchArg
            end
        end
    end
    if data.targetSwitches then
        local targetData = ZO_ShallowTableCopy(data)
        targetData.target = channelId
        for switchArg in data.targetSwitches:gmatch("%S+") do
            switchArg = switchArg:lower()
            g_switchLookup[switchArg] = targetData
            if not g_switchLookup[channelId] then
                g_switchLookup[channelId] = switchArg
            end
        end
    end
end
    return ChannelInfo
end
    return g_switchLookup
end
    return GetChatCategoryColor(MultiLevelEventToCategoryMappings[EVENT_CHAT_MESSAGE_CHANNEL][channelId])
end
    return MultiLevelEventToCategoryMappings, SimpleEventToCategoryMappings
end
    return TrialEventMappings
end