Files
LonaRPG-Online-Games/Data/Scripts/20_RubyTool.rb
T
2026-10-29 21:59:06 +04:00

39 lines
812 B
Ruby

# Ruby 3 native helpers used by the project.
class Integer
def num_digits
value = abs
return 1 if value < 1
Math.log10(value).to_i + 1
end
# Return an array containing each digit.
def split_digits
return [0] if zero?
res = []
quotient = abs
until quotient.zero?
quotient, modulus = quotient.divmod(10)
res.unshift(modulus)
end
res
end
end
module Kernel
$PRP_REC = [] unless defined?($PRP_REC) && $PRP_REC
$prp_console_enabled = false unless defined?($prp_console_enabled)
unless method_defined?(:_mp_prp_original_p)
alias _mp_prp_original_p p
end
def prp(val = nil, color = 0)
$PRP_REC = $PRP_REC.last(26) if $PRP_REC.length >= 27
$PRP_REC << [val, color]
_mp_prp_original_p(val) if $prp_console_enabled
val
end
end