/
bootstrap.lic
57 lines (49 loc) · 1.98 KB
/
bootstrap.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
# quiet
=begin
Documentation: https://elanthipedia.play.net/Lich_script_development#bootstrap
=end
class_defs = { 'equipmanager' => :EquipmentManager, 'common' => :DRC, 'common-travel' => :DRCT, 'common-crafting' => :DRCC, 'common-summoning' => :DRCS, 'common-money' => :DRCM, 'common-arcana' => :DRCA, 'common-items' => :DRCI, 'common-healing' => :DRCH, 'common-validation' => :CharacterValidator }
arg_definitions = [[{ name: 'wipe_constants', regex: /wipe_constants/i, optional: true }]]
args = parse_args(arg_definitions, true)
def constant_defined?(symbol)
if $MODERN_LICH && $MODERN_RUBY
Object.constants.include?(symbol)
else
Scripting.constants.include?(symbol)
end
end
def remove_constant(symbol)
if $MODERN_LICH && $MODERN_RUBY
Object.send(:remove_const, symbol)
else
Scripting.send(:remove_const, symbol)
end
end
RUBY_VERSION =~ /^(\d+)\.(\d+)\./
$MODERN_RUBY = Regexp.last_match(1).to_i > 2 || (Regexp.last_match(1).to_i == 2 && Regexp.last_match(2).to_i > 2)
LICH_VERSION =~ /^(\d+)\.(\d+)\./
$MODERN_LICH = Regexp.last_match(1).to_i > 4 || (Regexp.last_match(1).to_i == 4 && Regexp.last_match(2).to_i > 11)
if args.wipe_constants
class_defs.each_value { |symb| remove_constant(symb) if constant_defined?(symb) }
exit
end
scripts_to_run = args.flex
echo scripts_to_run.to_s if UserVars.bootstrap_debug
until scripts_to_run.empty?
script_to_run = scripts_to_run.shift
respond("BS:#{script_to_run}:#{scripts_to_run}") if UserVars.bootstrap_debug
next if Script.running?(script_to_run) || (class_defs[script_to_run] && constant_defined?(class_defs[script_to_run]))
respond("BS:Running #{script_to_run}") if UserVars.bootstrap_debug
exit unless verify_script(scripts_to_run)
start_script(script_to_run)
pause 0.05
snapshot = Time.now
if class_defs[script_to_run]
pause 0.05 until constant_defined?(class_defs[script_to_run])
pause 0.05
else
until !Script.running?(script_to_run) || Time.now - snapshot > 0.25
pause 0.05
end
end
end