-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathautostart.lic
More file actions
122 lines (115 loc) · 4.65 KB
/
autostart.lic
File metadata and controls
122 lines (115 loc) · 4.65 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#quiet
=begin
Automatically starts scripts when Lich starts.
;autostart help
author: Tillmen (tillmen@lichproject.org)
game: any
tags: core
version: 0.3
required: Lich >= 4.6.0
changelog:
0.3 (2014-11-23):
add default settings on first run
0.2 (2014-11-10):
auto add infomon to global autostart list
=end
if Settings['scripts'].nil?
Settings['scripts'] = Array.new
if XMLData.game =~ /^GS/
Settings['scripts'].push(:name => 'infomon', :args => [])
end
Settings['scripts'].push(:name => 'alias', :args => [])
Settings['scripts'].push(:name => 'lnet', :args => [])
Settings['scripts'].push(:name => 'repository', :args => ['download-updates'])
end
if script.vars.empty?
did_something = false
for script_list in [ Settings['scripts'], CharSettings['scripts'] ]
if script_list.class == Array
for script_info in script_list
start_script(script_info[:name], script_info[:args])
did_something = true
end
end
end
unless did_something
echo 'nothing to do'
end
elsif (script.vars[1] =~ /^add$/i) and script.vars[2] and (script.vars[3] or script.vars[2] !~ /^\-\-global$/i)
if script.vars[2] =~ /^\-\-global$/i
script_list = Settings['scripts']
script_list = Array.new unless script_list.class == Array
if not Script.exists?(script.vars[3])
respond "\n--- #{script.vars[3]} does not appear to be a valid script\n\n"
elsif script_list.any? { |s| s[:name] == script.vars[3].downcase }
respond "\n--- #{script.vars[3]} is already set to start at login for all characters\n\n"
else
script_list.push(:name => script.vars[3].downcase, :args => script.vars[4..-1])
Settings['scripts'] = script_list
respond "\n--- #{script.vars[3]} will now start at login for all characters\n\n"
end
else
script_list = CharSettings['scripts']
script_list = Array.new unless script_list.class == Array
if not Script.exists?(script.vars[2])
respond "\n--- #{script.vars[2]} does not appear to be a valid script\n\n"
elsif script_list.any? { |s| s[:name] == script.vars[2].downcase }
respond "\n--- #{script.vars[2]} is already set to start at login for #{Char.name}\n\n"
else
script_list.push(:name =>script.vars[2].downcase, :args => script.vars[3..-1])
CharSettings['scripts'] = script_list
respond "\n--- #{script.vars[2]} will now start at login for #{Char.name}\n\n"
end
end
elsif script.vars[1] =~ /^rem(?:ove)?$|^del(?:ete)?$/ and script.vars[2] and (script.vars[3] or script.vars[2] !~ /^\-\-global$/i)
if script.vars[2] =~ /^\-\-global$/i
script_list = Settings['scripts']
if (script_list.class == Array) and (script_info = script_list.find { |s| s[:name] == script.vars[3].downcase })
script_list.delete(script_info)
Settings['scripts'] = script_list
respond "\n--- #{script.vars[3]} was removed from the global autostart list\n\n"
else
respond "\n--- #{script.vars[3]} was not found in the global autostart list\n\n"
end
else
script_list = CharSettings['scripts']
if (script_list.class == Array) and (script_info = script_list.find { |s| s[:name] == script.vars[2].downcase })
script_list.delete(script_info)
CharSettings['scripts'] = script_list
respond "\n--- #{script.vars[2]} was removed from #{XMLData.name}'s autostart list\n\n"
else
respond "\n--- #{script.vars[2]} was not found in #{XMLData.name}'s autostart list\n\n"
end
end
elsif script.vars[1] =~ /^list$/i
script_list = Settings['scripts']
output = "\n--- Global autostart scripts: "
if (script_list.class == Array) and not script_list.empty?
output.concat script_list.collect { |script_info| if script_info[:args].empty?; script_info[:name]; else; "#{script_info[:name]} (args: #{script_info[:args].join(' ')})"; end }.join(', ')
output.concat "\n\n"
else
output.concat "(none)\n\n"
end
script_list = CharSettings['scripts']
output.concat "--- #{XMLData.name}'s autostart scripts: "
if (script_list.class == Array) and not script_list.empty?
output.concat script_list.collect { |script_info| if script_info[:args].empty?; script_info[:name]; else; "#{script_info[:name]} (args: #{script_info[:args].join(' ')})"; end }.join(', ')
output.concat "\n\n"
else
output.concat "(none)\n\n"
end
respond output
else
output = "\n"
output.concat "Usage:\n"
output.concat "\n"
output.concat " #{$clean_lich_char}autostart add <script name> <args>\n"
output.concat " #{$clean_lich_char}autostart add --global <script name> <args>\n"
output.concat "\n"
output.concat " #{$clean_lich_char}autostart remove <script name>\n"
output.concat " #{$clean_lich_char}autostart remove --global <script name>\n"
output.concat "\n"
output.concat " #{$clean_lich_char}autostart list\n"
output.concat "\n"
respond output
end