mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-04-21 21:52:04 +02:00
Merge pull request #62 from WaywardHeart/ruby_classic_wrap
Replace the ruby18_wrap.rb preload script with ruby_classic_wrap.rb
This commit is contained in:
commit
2d832934ff
3 changed files with 45 additions and 18 deletions
|
@ -318,7 +318,7 @@
|
|||
// execution starts
|
||||
// (default: none)
|
||||
//
|
||||
// "preloadScript": ["scripts/preload/ruby18_wrap.rb",
|
||||
// "preloadScript": ["scripts/preload/ruby_classic_wrap.rb",
|
||||
// "scripts/preload/mkxp_wrap.rb",
|
||||
// "scripts/preload/win32_wrap.rb"],
|
||||
|
||||
|
|
|
@ -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
|
44
scripts/preload/ruby_classic_wrap.rb
Normal file
44
scripts/preload/ruby_classic_wrap.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
# ruby_classic_wrap.rb
|
||||
# Author: WaywardHeart (2023)
|
||||
|
||||
# Creative Commons CC0: To the extent possible under law, WaywardHeart has
|
||||
# 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
|
Loading…
Add table
Reference in a new issue