forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.lic
67 lines (53 loc) · 1.14 KB
/
events.lic
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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_development#events
=end
no_kill_all
no_pause_all
setpriority(0)
class Flags
@@flags = {}
@@matchers = {}
def self.[](key)
@@flags[key]
end
def self.[]=(key, value)
@@flags[key] = value
end
def self.add(key, *matchers)
@@flags[key] = false
@@matchers[key] = matchers.map { |item| item.is_a?(Regexp) ? item : /#{item}/i }
end
def self.reset(key)
@@flags[key] = false
end
def self.delete(key)
@@matchers.delete key
@@flags.delete key
end
def self.flags
@@flags
end
def self.matchers
@@matchers
end
end
events_action = proc do |server_string|
Flags.matchers.each do |key, regexes|
regexes.each do |regex|
if (matches = server_string.match(regex))
Flags.flags[key] = matches
break
end
end
end
server_string
end
DownstreamHook.remove('events_action')
DownstreamHook.add('events_action', events_action)
before_dying do
DownstreamHook.remove('events_action')
end
until script.gets.nil?
# Keep script alive while game is connected
# so that we continue to receive and parse data.
end