Hello! I was wondering how to modify the Window_NumberInput class, I'm trying to create a slightly altered version of it, and i've ran into a few issues. First of all, and utilizing the original script which comes with VXAce, I'm not sure why this part of the code doesn't work when I create a Window_NumberInput object, yet it works perfectly fine when I create a number input window through the command events:
The commented one is the problematic method, self.openness, causing the system to freeze.
Second of all, and now with my own altered version of Window_InputNumber, I'm not sure why this is happening: Basically in my modified Window_NumberInput script, the 2 numbers don't actually show up until I move the cursors up or down. I tried messing around with the refresh and update methods, but those don't seem to be the cause of it. anyone has any theory on how to make it display both numbers by default? this is my altered script:
Spoiler
#==============================================================================
# ** Window_NumberInput
#------------------------------------------------------------------------------
# This window is used for the event command [Input Number].
#==============================================================================
class Window_NumberInputN < Window_Base
def initialize(message_window)
@message_window = message_window
super(0,0,70,50)
@number = 0
@digits_max = 2
@index = 0
update
#self.openness = 0
#deactivate
end
def start
@digits_max = 2
@number = $game_variables[0]
@number = [[@number, 0].max, 10 ** @digits_max - 1].min
@index = 0
update_placement
create_contents
refresh
open
activate
end
#--------------------------------------------------------------------------
# * Update Window Position
#--------------------------------------------------------------------------
def update_placement
self.width = @digits_max * 20 + padding * 2
self.height = fitting_height(1)
self.x = (Graphics.width - width) / 2
if @message_window.y >= Graphics.height / 2
self.y = @message_window.y - height - 8
else
self.y = @message_window.y + @message_window.height + 8
end
end
#--------------------------------------------------------------------------
# * Move Cursor Right
# wrap : Wraparound allowed
#--------------------------------------------------------------------------
def cursor_right(wrap)
if @index < @digits_max - 1 || wrap
@index = (@index + 1) % @digits_max
end
end
#--------------------------------------------------------------------------
# * Move Cursor Left
# wrap : Wraparound allowed
#--------------------------------------------------------------------------
def cursor_left(wrap)
if @index > 0 || wrap
@index = (@index + @digits_max - 1) % @digits_max
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
process_cursor_move
process_digit_change
process_handling
update_cursor
end
#--------------------------------------------------------------------------
# * Cursor Movement Processing
#--------------------------------------------------------------------------
def process_cursor_move
return unless active
last_index = @index
cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
cursor_left (Input.trigger?(:LEFT)) if Input.repeat?(:LEFT)
Sound.play_cursor if @index != last_index
end
#--------------------------------------------------------------------------
# * Change Processing for Digits
#--------------------------------------------------------------------------
def process_digit_change
return unless active
if Input.repeat?(:UP) || Input.repeat?(:DOWN)
Sound.play_cursor
place = 10 ** (@digits_max - 1 - @index)
n = @number / place % 10
@number -= n * place
n = (n + 1) % 10 if Input.repeat?(:UP)
n = (n + 9) % 10 if Input.repeat?(:DOWN)
@number += n * place
refresh
end
end
#--------------------------------------------------------------------------
# * Handling Processing for OK and Cancel
#--------------------------------------------------------------------------
def process_handling
return unless active
return process_ok if Input.trigger?(:C)
return process_cancel if Input.trigger?(:<img src='http://forums.rpgmakerweb.com/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' />
end
#--------------------------------------------------------------------------
# * Processing When OK Button Is Pressed
#--------------------------------------------------------------------------
def process_ok
Sound.play_ok
$game_variables[$game_message.num_input_variable_id] = @number
deactivate
close
end
#--------------------------------------------------------------------------
# * Processing When Cancel Button Is Pressed
#--------------------------------------------------------------------------
def process_cancel
deactivate
close
end
#--------------------------------------------------------------------------
# * Get Rectangle for Displaying Item
#--------------------------------------------------------------------------
def item_rect(index)
Rect.new(index * 20, 0, 20, line_height)
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
change_color(normal_color)
s = sprintf("%0*d", @digits_max, @number)
@digits_max.times do |i|
rect = item_rect(i)
rect.x += 1
draw_text(rect, s[i,1], 1)
end
end
#--------------------------------------------------------------------------
# * Update Cursor
#--------------------------------------------------------------------------
def update_cursor
cursor_rect.set(item_rect(@index))
end
end
It's actually mostly the same, except for a few changes in the initializations to make it work as I intend it to.
Edit: Duhhhhh nvm lol it was something really silly, I've fixed it now, this thread can get locked.