36 lines
1.4 KiB
Ruby
36 lines
1.4 KiB
Ruby
# encoding: UTF-8
|
|||
|
|
#==============================================================================
|
||
|
|
# LonaCraft: mkxp-z / Ruby 3.1.0 compatibility bootstrap for the 2026-10-09
|
||
|
|
# online build. Ruby310Compat belongs to the GAME, not the mod.
|
||
|
|
# This file does NOT change the Ruby interpreter used by Game.exe.
|
||
|
|
#==============================================================================
|
||
|
|
module LonaCraft
|
||
|
|
module Ruby310Runtime
|
||
|
|
def self.load_game_compat
|
||
|
|
return true if defined?(::Ruby310Compat)
|
||
|
|
candidates = [
|
||
|
|
File.join(Dir.pwd, "ModScripts/000_Ruby310_Compat.rb"),
|
||
|
|
File.join(Dir.pwd, "Data/Scripts/000_Ruby310_Compat.rb")
|
||
|
|
]
|
||
|
|
candidates.each do |path|
|
||
|
|
next unless File.file?(path)
|
||
|
|
load path
|
||
|
|
return true if defined?(::Ruby310Compat)
|
||
|
|
end
|
||
|
|
false
|
||
|
|
end
|
||
|
|
|
||
|
|
def self.check!
|
||
|
|
unless load_game_compat
|
||
|
|
raise LoadError, "LonaCraft needs the game's Ruby310Compat (ModScripts/000_Ruby310_Compat.rb or Data/Scripts/000_Ruby310_Compat.rb)"
|
||
|
|
end
|
||
|
|
# Ruby 3.1 separates keyword arguments from positional hashes.
|
||
|
|
# Aliases in date/menu hooks forward both **kwargs and &block.
|
||
|
|
if defined?(RUBY_VERSION) && RUBY_VERSION.split('.').map(&:to_i)[0] < 3
|
||
|
|
raise LoadError, "LonaCraft online build requires Ruby 3.x (detected #{RUBY_VERSION})"
|
||
|
|
end
|
||
|
|
true
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
LonaCraft::Ruby310Runtime.check!
|