-
Notifications
You must be signed in to change notification settings - Fork 0
/
valkyrie.lua
63 lines (53 loc) · 2.04 KB
/
valkyrie.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
_addon.name = 'Valkyrie'
_addon.author = 'Areint/Alzade'
_addon.version = '1.0.1'
_addon.commands = {'valk', 'valkyrie'}
--------------------------------------------------------------------------------
require('logger')
packets = require('util/packets')
settings = require('util/settings')
extdata = require('extdata')
local CommandFactory = require('command/factory')
local NilCommand = require('command/nil')
--------------------------------------------------------------------------------
local command = NilCommand:NilCommand()
--------------------------------------------------------------------------------
local function OnSuccess()
command = NilCommand:NilCommand()
end
--------------------------------------------------------------------------------
local function OnFailure()
command = NilCommand:NilCommand()
end
--------------------------------------------------------------------------------
local function OnLoad()
settings.load()
end
--------------------------------------------------------------------------------
local function OnCommand(cmd, p1)
if command:Type() == 'NilCommand' then
command = CommandFactory.CreateCommand(cmd, p1)
command:SetSuccessCallback(OnSuccess)
command:SetFailureCallback(OnFailure)
command()
else
log('Already running a complex command')
end
end
--------------------------------------------------------------------------------
local function OnIncomingData(id, _, pkt, b, i)
if not packets.is_duplicate(id, pkt) then
return command:OnIncomingData(id, pkt)
else
return false
end
end
--------------------------------------------------------------------------------
local function OnOutgoingData(id, _, pkt, b, i)
return command:OnOutgoingData(id, pkt)
end
--------------------------------------------------------------------------------
windower.register_event('load', OnLoad)
windower.register_event('addon command', OnCommand)
windower.register_event('incoming chunk', OnIncomingData)
windower.register_event('outgoing chunk', OnOutgoingData)