forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkill-counter.lic
More file actions
89 lines (77 loc) · 2.62 KB
/
kill-counter.lic
File metadata and controls
89 lines (77 loc) · 2.62 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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#kill-counter
=end
unless HAVE_GTK
respond
respond 'error: ruby-gtk bindings are not installed or failed to load'
respond
exit
end
class KillCounter
def initialize; end
def process_line?(line)
/^You search (?!around for a moment)/i =~ line
end
end
filter = KillCounter.new
window = nil
window_done = false
load_window_position = CharSettings['window_position'] || []
load_window_width = CharSettings['window_width'] || 300
load_window_height = CharSettings['window_height'] || 100
window_title = "#{checkname} Kill Counter"
save_window_position = nil
save_window_width = nil
save_window_height = nil
before_dying do
CharSettings['window_position'] = save_window_position if (save_window_position.class == Array) && (save_window_position[0].to_i >= 0) && (save_window_position[1].to_i >= 0)
CharSettings['window_width'] = save_window_width if (save_window_width.class == Integer) && (save_window_width > 100)
CharSettings['window_height'] = save_window_height if (save_window_height.class == Integer) && (save_window_height > 100)
Gtk.queue { window.destroy }
end
begin
k_counter = 0
k_counter_disp = nil
Gtk.queue do
vbox = Gtk::VBox.new
start_time = Gtk::Entry.new
start_time.editable = false
display_font = Pango::FontDescription.new
display_font.weight = Pango::FontDescription::WEIGHT_BOLD
start_time.modify_font(display_font)
time_obj = Time.now
start_time.text = "Start Time: #{time_obj.inspect}"
vbox.pack_start(start_time)
k_counter_disp = Gtk::Entry.new
k_counter_disp.editable = false
display_font = Pango::FontDescription.new
display_font.weight = Pango::FontDescription::WEIGHT_BOLD
k_counter_disp.modify_font(display_font)
vbox.pack_start(k_counter_disp)
window = Gtk::Window.new
window.title = window_title
window.keep_above = true
window.border_width = 1
window.resize(load_window_width, load_window_height)
unless load_window_position.empty?
window.move(load_window_position[0], load_window_position[1])
end
window.add(vbox)
window.signal_connect('delete_event') do
save_window_position = window.position
save_window_width = window.allocation.width
save_window_height = window.allocation.height
window_done = true
end
window.show_all
end
loop do
line = script.gets?
break if window_done
pause 0.05 unless line
next unless line
next unless filter.process_line?(line)
k_counter += 1
k_counter_disp.text = "Kill Count: #{k_counter}"
end
end