# encoding: UTF-8 #============================================================================== # ModScripts compatibility bootstrap. # Uses the canonical Ruby 3 / mkxp-z compat layer from Data/Scripts. #============================================================================== module ModRubyCompatBootstrap def self.candidates list = [] begin cwd = Dir.pwd.to_s unless cwd.nil? || cwd.empty? list << File.expand_path('Data/Scripts/000_Ruby310_Compat.rb', cwd) list << File.expand_path('000_Ruby310_Compat.rb', cwd) end rescue StandardError end begin script_dir = File.dirname(__FILE__) unless script_dir.nil? || script_dir.empty? root = File.expand_path('..', script_dir) list << File.expand_path('Data/Scripts/000_Ruby310_Compat.rb', root) end rescue StandardError end seen = {} list.compact.map { |entry| entry.to_s }.reject(&:empty?).select { |entry| seen[entry] ? false : (seen[entry] = true) } end def self.load_core! return true if defined?(Ruby310Compat) candidates.each do |path| next unless File.file?(path) load path return true if defined?(Ruby310Compat) end false rescue StandardError false end end ModRubyCompatBootstrap.load_core! unless defined?(Ruby310Compat) raise LoadError, 'Ruby310Compat core is unavailable (expected Data/Scripts/000_Ruby310_Compat.rb)' end Ruby310Compat.json_ready? rescue nil