RGSS scripts optimization

This commit is contained in:
DepressedTWM 2026-08-19 20:10:45 +04:00
parent 5e1ff7a294
commit bdcaa03e11
5 changed files with 10 additions and 10 deletions

View file

@ -90,7 +90,7 @@ class Window_InputNumber < Window_Base
self.contents.font.color = normal_color self.contents.font.color = normal_color
s = sprintf("%0*d", @digits_max, @number) s = sprintf("%0*d", @digits_max, @number)
if($game_switches[179] == true) if($game_switches[179] == true)
for i in 0...@digits_max (0...@digits_max).each do |i|
case i case i
when 0 when 0
self.contents.font.color = Window_Base.text_color(4) self.contents.font.color = Window_Base.text_color(4)
@ -104,7 +104,7 @@ class Window_InputNumber < Window_Base
self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1]) self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1])
end end
else else
for i in 0...@digits_max (0...@digits_max).each do |i|
self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1]) self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1])
end end
end end

View file

@ -47,7 +47,7 @@ class Window_Item < Window_Selectable
end end
@data = [] @data = []
# Add item # Add item
for i in 1...$data_items.size (1...$data_items.size).each do |i|
if $game_party.item_number(i) > 0 if $game_party.item_number(i) > 0
@data.push($data_items[i]) @data.push($data_items[i])
end end
@ -56,7 +56,7 @@ class Window_Item < Window_Selectable
@item_max = @data.size @item_max = @data.size
if @item_max > 0 if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32) self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max (0...@item_max).each do |i|
draw_item(i) draw_item(i)
end end
self.index = 0 if self.index == -1 self.index = 0 if self.index == -1

View file

@ -30,7 +30,7 @@ class Window_MainMenu < Window_Selectable
# Render menu # Render menu
self.contents = Bitmap.new(width - 32, 32) self.contents = Bitmap.new(width - 32, 32)
Language.register_text_sprite(self.class.name + "_contents", self.contents) Language.register_text_sprite(self.class.name + "_contents", self.contents)
for i in 0...@item_max (0...@item_max).each do |i|
draw_item(i, normal_color) draw_item(i, normal_color)
end end
self.z = 9998 self.z = 9998
@ -74,7 +74,7 @@ class Window_MainMenu < Window_Selectable
# Open/show the menu # Open/show the menu
def open def open
# redraw in case language has been updated # redraw in case language has been updated
for i in 0...@item_max (0...@item_max).each do |i|
draw_item(i, normal_color) draw_item(i, normal_color)
end end
self.opacity = 0 self.opacity = 0

View file

@ -28,7 +28,7 @@ class Window_NameEdit < Window_Base
# Fit name within maximum number of characters # Fit name within maximum number of characters
name_array = @name.split(//)[0...@max_char] name_array = @name.split(//)[0...@max_char]
@name = "" @name = ""
for i in 0...name_array.size (0...name_array.size).each do |i|
@name += name_array[i] @name += name_array[i]
end end
@default_name = @name @default_name = @name
@ -66,7 +66,7 @@ class Window_NameEdit < Window_Base
# Delete 1 text character # Delete 1 text character
name_array = @name.split(//) name_array = @name.split(//)
@name = "" @name = ""
for i in 0...name_array.size-1 (0...name_array.size-1).each do |i|
@name += name_array[i] @name += name_array[i]
end end
@index -= 1 @index -= 1
@ -81,7 +81,7 @@ class Window_NameEdit < Window_Base
self.contents.clear self.contents.clear
# Draw name # Draw name
name_array = @name.split('') name_array = @name.split('')
for i in 0...@max_char (0...@max_char).each do |i|
c = name_array[i] c = name_array[i]
if c == nil if c == nil
c = "_" c = "_"

View file

@ -218,7 +218,7 @@ class Window_Settings
# navigation # navigation
if Input.wheel_y != 0 if Input.wheel_y != 0
if (Input::key_press?(Input::key_from_name("Left Shift"))) if (Input::key_press?(Input::key_from_name("Left Shift")))
for _ in 0...Input.wheel_y.round.abs (0...Input.wheel_y.round.abs).each do |_|
Input.wheel_y.round > 0 ? @content.parameter_right : @content.parameter_left Input.wheel_y.round > 0 ? @content.parameter_right : @content.parameter_left
end end
else else