QUICK VX SCRIPT QUESTION REGARDING THIS CURSOR THING
Posts
Pages:
1
This script installs a very nice cursor, but I don't want it to move horizontally when it's idle. I've fiddled around with it and I only have a faint idea on which line does what. Basically I just want it to stay still when the player isn't doing anything like MOST rpg cursors do.
script:
edit: Oh also hide tags can't hide code tags.
script:
=begin
BigEd781's Improved Command Window
=end
module EdsCursorConfig
# image preferred size of 18x18
POINTER_NAME = 'Pointer'
end
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# * initialize
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_initialize :initialize
def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
@arrow_image = Cache.picture(EdsCursorConfig::POINTER_NAME)
@arrow_sprite = Sprite.new
@arrow_sprite.bitmap = Bitmap.new(@arrow_image .width + 7, @arrow_image .height)
@arrow_sprite.z = 999
@sprite_last_draw_x = 0
@sprite_inc_x = 1
@intern_frame_count = 0
@update_pointer = true
eds_pre_window_command_mod_initialize(width, commands, column_max, row_max, spacing)
end
#--------------------------------------------------------------------------
# * dispose
#--------------------------------------------------------------------------
def dispose
super
@arrow_sprite.dispose
end
#--------------------------------------------------------------------------
# * close
#--------------------------------------------------------------------------
def close
super
@arrow_sprite.visible = false
end
#--------------------------------------------------------------------------
# * open
#--------------------------------------------------------------------------
def open
super
@arrow_sprite.visible = true
end
#--------------------------------------------------------------------------
# * visible=
#--------------------------------------------------------------------------
def visible=(value)
super
@arrow_sprite.visible = value ? (@index != -1) : value
end
#--------------------------------------------------------------------------
# * active=
#--------------------------------------------------------------------------
def active=(value)
super
@update_pointer = value
end
#--------------------------------------------------------------------------
# * cursor_rect= (OVERWRITTEN)
#--------------------------------------------------------------------------
def cursor_rect=(rect)
offset_y = self.viewport.nil? ? 0 : self.viewport.rect.y
offset_x = self.viewport.nil? ? 0 : self.viewport.rect.x - self.viewport.ox
boost_y = @arrow_image.height >= 29 ? 0 : 29 - @arrow_image.height
@arrow_sprite.x = 5 + rect.x + self.x - (@arrow_image.width / 2) + offset_x
@arrow_sprite.y = rect.y + self.y + (@arrow_image.height / 2) + offset_y + boost_y
end
#--------------------------------------------------------------------------
# * update_cursor
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_update_cursor :update_cursor
def update_cursor
eds_pre_window_command_mod_update_cursor
@intern_frame_count += 1
draw_pointer
end
#--------------------------------------------------------------------------
# * draw_pointer
#--------------------------------------------------------------------------
def draw_pointer
return unless @update_pointer
return unless (@intern_frame_count % 5) == 0
@arrow_sprite.bitmap.clear
return if @index == -1
if @sprite_last_draw_x == 7
@sprite_inc_x = -1
elsif @sprite_last_draw_x == 0
@sprite_inc_x = 1
end
x = @sprite_last_draw_x + @sprite_inc_x
@sprite_last_draw_x = x
@arrow_sprite.bitmap.blt(x, 0, @arrow_image, @arrow_image.rect)
end
end
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# * active=
#--------------------------------------------------------------------------
def active=(value)
super
@arrow_sprite.visible = value
end
end
class Window_Skill < Window_Selectable
#--------------------------------------------------------------------------
# * active=
#--------------------------------------------------------------------------
def active=(value)
super
@arrow_sprite.visible = value
end
end
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * cursor_rect= (OVERWRITTEN)
#--------------------------------------------------------------------------
def cursor_rect=(rect)
@arrow_sprite.x = rect.x + self.x - 16
@arrow_sprite.y = rect.y + self.y + 48
end
#--------------------------------------------------------------------------
# * active=
#--------------------------------------------------------------------------
def active=(value)
super
@arrow_sprite.visible = value
end
#--------------------------------------------------------------------------
# * update_cursor
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_stat_update_cursor :update_cursor
def update_cursor
eds_pre_window_command_mod_stat_update_cursor
@intern_frame_count += 1
draw_pointer
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * start_main
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_start_main :start_main
def start_main
@party_command_window.visible = false
@actor_command_window.visible = false
eds_pre_window_command_mod_start_main
end
#--------------------------------------------------------------------------
# * start_party_command_selection
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_start_party_command_selection :start_party_command_selection
def start_party_command_selection
@party_command_window.visible = true
eds_pre_window_command_mod_start_party_command_selection
@actor_command_window.visible = false
end
#--------------------------------------------------------------------------
# * start_actor_command_selection
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_start_actor_command_selection :start_actor_command_selection
def start_actor_command_selection
@actor_command_window.visible = true
eds_pre_window_command_mod_start_actor_command_selection
@party_command_window.visible = false
end
end
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# * update_cursor
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_win_mes_update_cursor :update_cursor
def update_cursor
eds_pre_window_command_mod_win_mes_update_cursor
@intern_frame_count += 1
draw_pointer
end
end
BigEd781's Improved Command Window
=end
module EdsCursorConfig
# image preferred size of 18x18
POINTER_NAME = 'Pointer'
end
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# * initialize
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_initialize :initialize
def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
@arrow_image = Cache.picture(EdsCursorConfig::POINTER_NAME)
@arrow_sprite = Sprite.new
@arrow_sprite.bitmap = Bitmap.new(@arrow_image .width + 7, @arrow_image .height)
@arrow_sprite.z = 999
@sprite_last_draw_x = 0
@sprite_inc_x = 1
@intern_frame_count = 0
@update_pointer = true
eds_pre_window_command_mod_initialize(width, commands, column_max, row_max, spacing)
end
#--------------------------------------------------------------------------
# * dispose
#--------------------------------------------------------------------------
def dispose
super
@arrow_sprite.dispose
end
#--------------------------------------------------------------------------
# * close
#--------------------------------------------------------------------------
def close
super
@arrow_sprite.visible = false
end
#--------------------------------------------------------------------------
# * open
#--------------------------------------------------------------------------
def open
super
@arrow_sprite.visible = true
end
#--------------------------------------------------------------------------
# * visible=
#--------------------------------------------------------------------------
def visible=(value)
super
@arrow_sprite.visible = value ? (@index != -1) : value
end
#--------------------------------------------------------------------------
# * active=
#--------------------------------------------------------------------------
def active=(value)
super
@update_pointer = value
end
#--------------------------------------------------------------------------
# * cursor_rect= (OVERWRITTEN)
#--------------------------------------------------------------------------
def cursor_rect=(rect)
offset_y = self.viewport.nil? ? 0 : self.viewport.rect.y
offset_x = self.viewport.nil? ? 0 : self.viewport.rect.x - self.viewport.ox
boost_y = @arrow_image.height >= 29 ? 0 : 29 - @arrow_image.height
@arrow_sprite.x = 5 + rect.x + self.x - (@arrow_image.width / 2) + offset_x
@arrow_sprite.y = rect.y + self.y + (@arrow_image.height / 2) + offset_y + boost_y
end
#--------------------------------------------------------------------------
# * update_cursor
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_update_cursor :update_cursor
def update_cursor
eds_pre_window_command_mod_update_cursor
@intern_frame_count += 1
draw_pointer
end
#--------------------------------------------------------------------------
# * draw_pointer
#--------------------------------------------------------------------------
def draw_pointer
return unless @update_pointer
return unless (@intern_frame_count % 5) == 0
@arrow_sprite.bitmap.clear
return if @index == -1
if @sprite_last_draw_x == 7
@sprite_inc_x = -1
elsif @sprite_last_draw_x == 0
@sprite_inc_x = 1
end
x = @sprite_last_draw_x + @sprite_inc_x
@sprite_last_draw_x = x
@arrow_sprite.bitmap.blt(x, 0, @arrow_image, @arrow_image.rect)
end
end
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# * active=
#--------------------------------------------------------------------------
def active=(value)
super
@arrow_sprite.visible = value
end
end
class Window_Skill < Window_Selectable
#--------------------------------------------------------------------------
# * active=
#--------------------------------------------------------------------------
def active=(value)
super
@arrow_sprite.visible = value
end
end
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * cursor_rect= (OVERWRITTEN)
#--------------------------------------------------------------------------
def cursor_rect=(rect)
@arrow_sprite.x = rect.x + self.x - 16
@arrow_sprite.y = rect.y + self.y + 48
end
#--------------------------------------------------------------------------
# * active=
#--------------------------------------------------------------------------
def active=(value)
super
@arrow_sprite.visible = value
end
#--------------------------------------------------------------------------
# * update_cursor
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_stat_update_cursor :update_cursor
def update_cursor
eds_pre_window_command_mod_stat_update_cursor
@intern_frame_count += 1
draw_pointer
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * start_main
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_start_main :start_main
def start_main
@party_command_window.visible = false
@actor_command_window.visible = false
eds_pre_window_command_mod_start_main
end
#--------------------------------------------------------------------------
# * start_party_command_selection
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_start_party_command_selection :start_party_command_selection
def start_party_command_selection
@party_command_window.visible = true
eds_pre_window_command_mod_start_party_command_selection
@actor_command_window.visible = false
end
#--------------------------------------------------------------------------
# * start_actor_command_selection
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_start_actor_command_selection :start_actor_command_selection
def start_actor_command_selection
@actor_command_window.visible = true
eds_pre_window_command_mod_start_actor_command_selection
@party_command_window.visible = false
end
end
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# * update_cursor
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_win_mes_update_cursor :update_cursor
def update_cursor
eds_pre_window_command_mod_win_mes_update_cursor
@intern_frame_count += 1
draw_pointer
end
end
edit: Oh also hide tags can't hide code tags.
You can find the line in def draw_pointer:
and just change it to:
It's a pretty dirty hack, but should work.
x = @sprite_last_draw_x + @sprite_inc_x
and just change it to:
x = 0
It's a pretty dirty hack, but should work.
Pages:
1














