-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.lua
More file actions
104 lines (86 loc) · 3.08 KB
/
core.lua
File metadata and controls
104 lines (86 loc) · 3.08 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
96
97
98
99
100
101
102
103
104
local addonName, ns = ...
local ta = LibStub("AceAddon-3.0"):NewAddon("ToshAssignments", "AceEvent-3.0", "AceComm-3.0", "AceConsole-3.0")
ns.ta = ta
local IsInGroup, UnitName = IsInGroup, UnitName
function ta:Debug(...)
if ViragDevTool_AddData then ViragDevTool_AddData(...) end
end
function ta:OnInitialize()
self:RegisterChatCommand("ta", "ChatCommand")
self:Print("/ta initialized")
end
function ta:ChatCommand(input)
local subcmd, rest = input:match("(%w+)(.*)")
self:Debug({input=input, subcmd=subcmd, rest=rest}, "/ta")
if subcmd == "test" then
local atype = "TIMER" -- default to timer test
if rest ~= "" then
atype = rest:match("%u+")
end
local player = UnitName("player")
local players = {[player]=player}
if atype == "TIMER" then
self:SendAssign(atype, players, {
spellid = 740,
duration = 10,
text = "TEST",
})
elseif atype == "UF" then
self:SendAssign(atype, players, {
uid = "player",
spellid = 740,
duration = 10,
category = "INFO",
})
elseif atype == "NP" then
self:SendAssign(atype, players, {
guid = UnitGUID("target"),
spellid = 740,
duration = 10,
})
end
end
end
do
local function noop() end
ta.Encode = noop
ta.Decode = noop
end
-- Local AceEvent Hooks/Translations
function ta:TOSH_ASSIGN_SEND(atype, players, args)
self:SendAssign(atype, players, args)
end
ta:RegisterMessage("TOSH_ASSIGN_SEND")
-- Addon Comm Send/Receive
function ta:OnCommReceived(...)
local event, msg = ...
local id, players, atype, args = self:Decode(msg)
self:Debug({comm={...}, id=id, players=players, atype=atype, args=args}, "TOSH_ASSIGN OnCommReceived")
self:SendMessage("TOSH_ASSIGN_"..atype, id, players, args)
end
ta:RegisterComm('TOSH_ASSIGN')
do
local nextid = 1
function ta:SendAssign(atype, players, args)
local id = nextid
nextid = nextid+1
local channel
if IsInGroup(LE_PARTY_CATEGORY_INSTANCE) or IsInRaid(LE_PARTY_CATEGORY_INSTANCE) then
channel = "INSTANCE_CHAT"
elseif IsInRaid(LE_PARTY_CATEGORY_HOME) then
channel = "RAID"
elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
channel = "PARTY"
end
if channel then
local v, msg = self:Encode(atype, id, players, args)
self:Debug({channel=channel, v=v, msg=msg, atype=atype, players=players, args=args}, "TOSH_ASSIGN SendAssign (addon)")
if not channel then return end
self:SendCommMessage('TOSH_ASSIGN', msg, channel)
else -- Mostly for testing
-- Skip the Addon Message channel and pass straight as an AceEvent message
self:Debug({atype=atype, players=players, args=args}, "TOSH_ASSIGN SendAssign (aceevent)")
self:SendMessage("TOSH_ASSIGN_"..atype, id, players, args)
end
end
end