-
-
Save rcuhljr/3e4389174d14536e66b5895460a4b06c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 RUBY_VERSION =~ /^2\.[012]\./ | |
Scripting.constants.include?(symbol) | |
else | |
Object.constants.include?(symbol) | |
end | |
end | |
def remove_constant(symbol) | |
if RUBY_VERSION =~ /^2\.[012]\./ | |
Scripting.send(:remove_const,symbol) | |
else | |
Object.send(:remove_const,symbol) | |
end | |
end | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment