Bigace360 38 Report post Posted November 12, 2012 Okay I'm having trouble scripting, I'm trying to create pages but I don't know where to start. I wanted it to look the item window, where you have a bunch of item and instead of scrolling down you scroll left or right sense there pages. Any help can be apprieciated so I can finish this script faster. Share this post Link to post Share on other sites
Moonpearl 32 Report post Posted November 12, 2012 Well basically you have to rewrite the Window_Selectable class (or a copy of it). The simplest solution to me would be to prevent the window from scrolling down when you use only the arrows, or have it scroll one page down when you do so, instead of one item down. Look at the code in Window_Selectable#update that runs when the user presses L or R (which are supposed to scroll one page up/down themselves), and use a copy of it to replace the code that runs when you press UP/DOWN and the previous/next item is out of the page. Share this post Link to post Share on other sites
diagostimo 11 Report post Posted November 12, 2012 (edited) i made a rewrite a little while ago of Window_Selectable to act like such: #============================================================================== # ** Window_Horizontal #------------------------------------------------------------------------------ # This window class contains horizontal cursor movement and scroll functions. #============================================================================== class Window_Horizontal < Window_Base #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :index #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) @item_max = 1 @row_max = 1 @index = -1 @cursor_width = 32 @offset = 32 end #-------------------------------------------------------------------------- # * Set Cursor Position # index : new cursor position #-------------------------------------------------------------------------- def index=(index) @index = index # Update cursor rectangle update_cursor_rect end #-------------------------------------------------------------------------- # * Get Column Count #-------------------------------------------------------------------------- def column_max # Compute columns from number of items and columns return (@item_max + @row_max - 1) / @row_max end #-------------------------------------------------------------------------- # * Get Left Column #-------------------------------------------------------------------------- def left_column # Divide x-coordinate of window contents transfer origin by 1 column # width of cursor width return self.ox / (@cursor_width + @offset) end #-------------------------------------------------------------------------- # * Set Left Column # column : column shown on Left #-------------------------------------------------------------------------- def left_column=(column) # If column is less than 0, change it to 0 if column < 0 column = 0 end # If column exceeds column_max - 1, change it to column_max - 1 if column > column_max - 1 column = column_max - 1 end # Multiply 1 column width by cursor width for x-coordinate of window contents # transfer origin self.ox = column * (@cursor_width + @offset) end #-------------------------------------------------------------------------- # * Get Number of Columns Displayable on 1 Page #-------------------------------------------------------------------------- def page_column_max # Subtract a frame width of 32 from the window width, and divide it by # 1 column width of cursor width return (self.width - 32) / (@cursor_width + @offset) end #-------------------------------------------------------------------------- # * Get Number of Items Displayable on 1 Page #-------------------------------------------------------------------------- def page_item_max # Multiply column count (page_column_max) times column count (@column_max) return page_column_max * @row_max end #-------------------------------------------------------------------------- # * Update Cursor Rectangle #-------------------------------------------------------------------------- def update_cursor_rect # If cursor position is less than 0 if @index < 0 self.cursor_rect.empty return end # Get current column column = @index / @row_max # If current column is before left column if column < self.left_column # Scroll so that current column becomes left column self.left_column = column end # If current column is more to right than right column if column > self.left_column + (self.page_column_max - 1) # Scroll so that current column becomes back column self.left_column = column - (self.page_column_max - 1) end # Calculate cursor coordinates x = 16 + (@index / @row_max * (@cursor_width + @offset) - self.ox) y = @index % @row_max * 32 # Update cursor rectangle self.cursor_rect.set(x, y, @cursor_width, 32) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super # If cursor is movable if self.active and @item_max > 0 and @index >= 0 # If pressing down on the directional buttons if Input.repeat?(Input::DOWN) # If row count is 2 or more, and cursor position is closer to front # than (item count -1) if @row_max >= 2 and @index < @item_max - 1 # Move cursor right $game_system.se_play($data_system.cursor_se) @index += 1 end end # If the up directional button was pressed if Input.repeat?(Input::UP) # If row count is 2 or more, and cursor position is more back than 0 if @row_max >= 2 and @index > 0 # Move cursor left $game_system.se_play($data_system.cursor_se) @index -= 1 end end # If the right directional button was pressed if Input.repeat?(Input::RIGHT) # If row count is 1 and directional button was pressed down with no # repeat, or if cursor position is more to the front than # (item count - row count) if (@row_max == 1 and Input.trigger?(Input::RIGHT)) or @index < @item_max - @row_max # Move cursor down $game_system.se_play($data_system.cursor_se) @index = (@index + @row_max) % @item_max elsif @index >= (@item_max - 1) - @row_max @index = @item_max - 1 end end # If the left directional button was pressed if Input.repeat?(Input::LEFT) # If row count is 1 and directional button was pressed up with no # repeat, or if cursor position is more to the back than row count if (@row_max == 1 and Input.trigger?(Input::LEFT)) or @index >= @row_max # Move cursor up $game_system.se_play($data_system.cursor_se) @index = (@index - @row_max + @item_max) % @item_max end end end # Update cursor rectangle update_cursor_rect end end so basicly just make your window have the parent of Window_Horizontal like you would with any other window that uses Window_selectable, the main variables to take note of are in the initialize method: @item_max = 1 #the maximum number of items to scroll through @row_max = 1 #the maximum number of rows(verticaly) @index = -1 #the initializing index value @cursor_width = 32 #the cursors width @offset = 32 #spacing between each cursor point as you said you wanted pages, if you didnt want the cursor some minor editing would be needed to set the pages width(you could use the cursors width varialbe) and you would need to remove the part that draws the cursor, as for removing up and down scrolling just leave @row_max as 1 Edited November 12, 2012 by diagostimo Share this post Link to post Share on other sites
Bigace360 38 Report post Posted November 12, 2012 Thank you both of you, I'll test diagostimo's method in a minute. Share this post Link to post Share on other sites