Replace the ruby18_wrap.rb preload script with ruby_classic_wrap.rb

This commit is contained in:
Wayward Heart 2023-10-17 07:40:58 -05:00
parent 986875a144
commit 778c7e63b9
2 changed files with 43 additions and 17 deletions

View file

@ -1,17 +0,0 @@
# ruby18_wrap.rb
# Author: Splendide Imaginarius (2022)
# Creative Commons CC0: To the extent possible under law, Splendide Imaginarius
# has waived all copyright and related or neighboring rights to ruby18_wrap.rb.
# https://creativecommons.org/publicdomain/zero/1.0/
# This preload script provides functions that existed in RPG Maker's Ruby v1.8,
# but were renamed in the current Ruby version used in mkxp-z, so that games
# (or other preload scripts) that expect Ruby v1.8's function names can find
# them.
class Hash
def index(*args)
key(*args)
end
end

View file

@ -0,0 +1,43 @@
# ruby_classic_wrap.rb
# Creative Commons CC0: To the extent possible under law, the author(s) have
# dedicated all copyright and related and neighboring rights to this script
# to the public domain worldwide.
# https://creativecommons.org/publicdomain/zero/1.0/
# This preload script provides functions that existed in RPG Maker's versions of Ruby,
# but were renamed or changed in the current Ruby version used in mkxp-z, so that games
# (or other preload scripts) that expect the older Ruby behavior can function.
class Hash
alias_method :index, :key unless method_defined?(:index)
end
class Object
TRUE = true unless const_defined?("TRUE")
FALSE = false unless const_defined?("FALSE")
NIL = nil unless const_defined?("NIL")
alias_method :id, :object_id unless method_defined?(:id)
alias_method :type, :class unless method_defined?(:type)
end
class NilClass
def id
4 # Starting with Ruby2, 64-bit builds of ruby make this 8
end
end
class TrueClass
def id
2 # Starting with Ruby2, 64-bit builds of ruby make this 20
end
end
if defined?(BasicObject) && BasicObject.instance_method(:initialize).arity == 0
# In ruby 1.9.2, and only ruby 1.9.2, BasicObject.initialize accepted any number of arguments
class BasicObject
def initialize(*args)
end
end
end