-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlerts.lua
More file actions
57 lines (42 loc) · 1.59 KB
/
Alerts.lua
File metadata and controls
57 lines (42 loc) · 1.59 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
local _, addon = ...
local SendAddonMessage = C_ChatInfo.SendAddonMessage
local alert
local function initAlerts()
alert = addon.CreateText('alertPrimary', 'LOREM IPSUM', 'ALERT')
end
local function showAlert(channel, ...)
local msg, _ = ...
local resp = 'alertShowAck ' .. string.format('%s:%s', addon.CLIENT_VERSION, addon.PlayerClass)
for name, text in string.gmatch(msg, '"([^"]+)":"([^"]+)"') do
if name == addon.PlayerNameRealm or name == UnitName('player') then
alert:SetText(text)
addon.ShowText('alertPrimary')
SendAddonMessage(AstralRaidComms.PREFIX, resp, channel)
return
end
end
end
local function hideAlert(channel, ...)
local msg, _ = ...
local resp = 'alertHideAck ' .. string.format('%s:%s', addon.CLIENT_VERSION, addon.PlayerClass)
for name, text in string.gmatch(msg, '"([^"]+)":"([^"]+)"') do
if name == addon.PlayerNameRealm or name == UnitName('player') then
alert:SetText(text)
addon.HideText('alertPrimary')
SendAddonMessage(AstralRaidComms.PREFIX, resp, channel)
return
end
end
end
AstralRaidComms:RegisterPrefix('RAID', 'alertShow', function(...) showAlert('RAID', ...) end)
AstralRaidComms:RegisterPrefix('RAID', 'alertHide', function(...) hideAlert('RAID', ...) end)
AstralRaidEvents:Register('PLAYER_LOGIN', initAlerts, 'InitAlerts')
-- Library Hooks
function AstralRaidLibrary:ShowAlert(text, time)
alert:SetText(text)
addon.ShowText('alertPrimary')
if time then C_Timer.After(time, function() addon.HideText('alertPrimary') end) end
end
function AstralRaidLibrary:HideAlert()
addon.HideText('alertPrimary')
end