Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Warped movement for Window Selectable, I was bored
Zeriab
post Aug 26 2007, 05:27 AM
Post #1


Level 12
Group Icon

Group: Revolutionary
Posts: 196
Type: Event Designer
RM Skill: Skilled




Hey all
I was a bit bored and fiddled around with the movement of Window_Items. I found the way I represent here better. I decided to make it broader and have created a solution intended for subclasses of Window_Selectable
I will provide two versions. One if you want to only apply this on certain windows and not others. Another that just changes the functionality of Window_Selectable.

Here is the mix-in version for changing specific classes:
CODE
#==============================================================================
# ** Warped Movement mix-in for subclasses of Window Selectable
#------------------------------------------------------------------------------
# Zeriab
# Version 1.0
# 2007-08-22 (Year-Month-Day)
#------------------------------------------------------------------------------
# * Description :
#
#   This is a mix-in module for windows subclassing designed to 'enhance' the
#   arrow-key movement system used to select the item by creating warping.
#   That is, if you are at the bottom and press down you will go up to the top
#   in the next column. Like-wise for down, left and right.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place the script anywhere above Main.
#   To give a subclass of Window_Selectable let it include the module
#
#   If you for example wanted to apply the module to Window_Item you should
#   write this code: (Must be below the original Window_Item
# ------------------------------------------
#   class Window_Item < Window_Selectable
#     include Window_Selectable_Type_2
#   end
# ------------------------------------------
#
#   Here is a version for Window_Skill. You get the idea.
# ------------------------------------------
#   class Window_Skill < Window_Selectable
#     include Window_Selectable_Type_2
#   end
# ------------------------------------------
#
#   Note: Don't include this module in Window_Selectable ~
#         May cause issues with Windows where the update method is used
#==============================================================================

#==============================================================================
# ** module Window_Selectable_Warped
#==============================================================================
module Window_Selectable_Warped
  #----------------------------------------------------------------------------
  # * Frame Update
  #----------------------------------------------------------------------------
  def update
    last_index = @index
    super
    if last_index == @index && active && @item_max > 1
      if Input.repeat?(Input::DOWN)
        # Move cursor down
        $game_system.se_play($data_system.cursor_se)
        @index = (@index % @column_max + 1) % @column_max
      end
      # If the up directional button was pressed
      if Input.repeat?(Input::UP)
        # Move cursor up
        $game_system.se_play($data_system.cursor_se)
      @index = (@index % @column_max + 1)
      @index = -@index % @item_max + @item_max % @column_max
      @index -= @column_max  if @index >= @item_max
      end
      # If the right directional button was pressed
      if Input.repeat?(Input::RIGHT)
        # Move cursor right
        $game_system.se_play($data_system.cursor_se)
        @index = (@index + 1) % @item_max
      end
      # If the left directional button was pressed
      if Input.repeat?(Input::LEFT)
        # Move cursor left
        $game_system.se_play($data_system.cursor_se)
        @index = (@index - 1) % @item_max
      end
    end
  end
end


Next we have the change for all Window_Selectable subclasses. This also requires less work.
CODE
#==============================================================================
# ** Warped Movement for Window Selectable
#------------------------------------------------------------------------------
# Zeriab
# Version 1.0
# 2007-08-22 (Year-Month-Day)
#------------------------------------------------------------------------------
# * Description :
#
#   This script is designed to 'enhance' the arrow-key movement system of
#   Window_Selectable used to select the item by allowing warping.
#   That is, if you are at the bottom and press down you will go up to the top
#   in the next column. Like-wise for down, left and right.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place the script below Window_Selectable and above Main.
#
#   Note: May cause issue with scripts that are depent on the index not
#         changing under certain circumstances
#==============================================================================

#==============================================================================
# ** Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
  alias zeriab_warped_update update
  #----------------------------------------------------------------------------
  # * Frame Update
  #----------------------------------------------------------------------------
  def update
    last_index = @index
    # original update method is called
    zeriab_warped_update
    if last_index == @index && active && @item_max > 1
      if Input.repeat?(Input::DOWN)
        # Move cursor down
        $game_system.se_play($data_system.cursor_se)
        @index = (@index % @column_max + 1) % @column_max
      end
      # If the up directional button was pressed
      if Input.repeat?(Input::UP)
        # Move cursor up
        $game_system.se_play($data_system.cursor_se)
      @index = (@index % @column_max + 1)
      @index = -@index % @item_max + @item_max % @column_max
      @index -= @column_max  if @index >= @item_max
      end
      # If the right directional button was pressed
      if Input.repeat?(Input::RIGHT)
        # Move cursor right
        $game_system.se_play($data_system.cursor_se)
        @index = (@index + 1) % @item_max
      end
      # If the left directional button was pressed
      if Input.repeat?(Input::LEFT)
        # Move cursor left
        $game_system.se_play($data_system.cursor_se)
        @index = (@index - 1) % @item_max
      end
    end
  end
end

Instructions are in the script header. Enjoy ~

- Zeriab


__________________________
Go to the top of the page
 
+Quote Post
   
Guest_RPG Wizard_*
post Aug 27 2007, 07:56 PM
Post #2





Guests





Useful and nifty smile.gif Nice work, keep it up!
Go to the top of the page
 
+Quote Post
   
returningshadow
post May 29 2008, 01:28 AM
Post #3


The Whisperer - Coming 2010
Group Icon

Group: Revolutionary
Posts: 231
Type: Developer
RM Skill: Advanced




Sorry, I'm new to scripting - can you please tell me in idiot language what this script does? happy.gif


__________________________
Go to the top of the page
 
+Quote Post
   
Zeriab
post May 29 2008, 08:02 AM
Post #4


Level 12
Group Icon

Group: Revolutionary
Posts: 196
Type: Event Designer
RM Skill: Skilled




The script changes how the control of the menu works.
It is a bit difficult to explain what the script does.
It's easier to feel how it works.
I suggest you make a new project and try the code in the second code block. Try how it works when you press the arrow keys in the menus.

If you figure out to explain what the script does in a nice and easy understandable way please let me know.

*hugs*
- Zeriab


__________________________
Go to the top of the page
 
+Quote Post
   
TheBloodRed
post Jun 7 2008, 01:28 PM
Post #5



Group Icon

Group: Banned
Posts: 0
Type: None
RM Skill: Undisclosed




This is actually pretty good work. Thanks! biggrin.gif


__________________________
Don't post porn like I did!


This Public Safety Announcement is brought to you by the leadership team of RRR.
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 07:49 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker