#==============================================================================
# Input Number with Numpad Author: KK20
# Date: Mar 10 2024
#------------------------------------------------------------------------------
# Allows the use of the numpad keys to input a number when using the "Input
# Number" event command. Requires "Custom Game Controls" from Tons of Add-ons:
# https://forum.chaos-project.com/index.php/topic,105.0.html
#
# This script should be placed below Tons of Add-ons.
# No other instructions, this is plug-n-play.
#==============================================================================
module Input
Key['NumberPad 0'] = 0x60
Key['NumberPad 1'] = 0x61
Key['NumberPad 2'] = 0x62
Key['NumberPad 3'] = 0x63
Key['NumberPad 4'] = 0x64
Key['NumberPad 5'] = 0x65
Key['NumberPad 6'] = 0x66
Key['NumberPad 7'] = 0x67
Key['NumberPad 8'] = 0x68
Key['NumberPad 9'] = 0x69
def self.numpad_keys
[Key['NumberPad 7'], Key['NumberPad 8'], Key['NumberPad 9'],
Key['NumberPad 4'], Key['NumberPad 5'], Key['NumberPad 6'],
Key['NumberPad 1'], Key['NumberPad 2'], Key['NumberPad 3'],
Key['NumberPad 0']]
end
end
#==============================================================================
# ** Window_InputNumber
#------------------------------------------------------------------------------
# This window is for inputting numbers, and is used within the
# message window.
#==============================================================================
class Window_InputNumber < Window_Base
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias update_for_arrow_keys update
def update
num = nil
if Input.repeat?(Input.numpad_keys) || Input.repeat?(Input::B)
super
num =
if Input.repeat?(Input::Key['NumberPad 0']) then 0
elsif Input.repeat?(Input::Key['NumberPad 1']) then 1
elsif Input.repeat?(Input::Key['NumberPad 2']) then 2
elsif Input.repeat?(Input::Key['NumberPad 3']) then 3
elsif Input.repeat?(Input::Key['NumberPad 4']) then 4
elsif Input.repeat?(Input::Key['NumberPad 5']) then 5
elsif Input.repeat?(Input::Key['NumberPad 6']) then 6
elsif Input.repeat?(Input::Key['NumberPad 7']) then 7
elsif Input.repeat?(Input::Key['NumberPad 8']) then 8
elsif Input.repeat?(Input::Key['NumberPad 9']) then 9
end
if num
$game_system.se_play($data_system.cursor_se)
# Get current place number and change it to 0
place = 10 ** (@digits_max - 1 - @index)
n = @number / place % 10
@number -= n * place
# Reset current place number
@number += num * place
# move cursor right
@index = [@index + 1, @digits_max - 1].min
else
$game_system.se_play($data_system.buzzer_se)
# Get current place number and change it to 0
place = 10 ** (@digits_max - 1 - @index)
n = @number / place % 10
@number -= n * place
# move cursor left
@index = [@index - 1, 0].max
end
update_cursor_rect
refresh
return
end
update_for_arrow_keys
end
end