Victor Sant Materia + Shaz Materia mouse addon

A while ago I got some help from shaz with using her mouse script and victor sants materia script.
https://forums.rpgmakerweb.com/index.php?threads/victor-sant-materia-shaz-mouse.70191/

The attached script there fixes the error I was getting, but now I've gone back to try and see if I can improve it.

I did have some success and wonder if someone can help with the remaining part.
When changing one line I got the mouse to select the materia slots from left to right, but it does not move up or down to select different equipment.
Line 20 changed to
Code:
for i in 0 ... actor.materia_slots[equip].size#item_max

Everything I tried to get the mouse to recognize that it can select up or down does not happen.
I tried a piece from shaz's mouse script to see if it would work but to no avail. (with changes)
Code:
    if equip != @equip
      if @index > last_index
        cursor_down(false)
      else
        cursor_up(false)
      end
      Sound.play_cursor
    end
You may want to setup a demo project with this, because it involves more than 1 custom script and even edits to those.
I would try to help, but I got no time to setup a working project with these scripts just so I can test them out.
If you make a demo (with everything setup to check the issue), I will try to look at it when I get a little free time.
If you can help, that would be awesome. I was able to remake the problem in a new project. I had to use the original scripts as I have partial edits that do not work without other supporting scripts. But it should not matter as the problem is still there. I'm sure if you can make it work with this then it would work in my project as well. It is a very specific issue. Well at least to my understanding.
Sending you my entire script list would be quite a lot for you to sift through, plus I would have to include graphics and other files.
http://www.mediafire.com/file/rd7ipxg7ciuhnw0/Mouse plus Materia.zip
Excuse the late reply, too busy nowadays.

Try this patch:
Spoiler
Code:
class Window_MateriaEquip < Window_Selectable
 
  alias add_delay8815 initialize
  def initialize
    @delay = 0
    add_delay8815
  end
    
  def process_mouse_handling
    return unless $mouse.enabled? && cursor_movable?
    # Add a delay to prevent too-fast scrolling
    if @delay > 0
      @delay -= 1
    else
      mx, my = *Mouse.position
      vx = self.viewport ? self.x - self.viewport.ox + self.viewport.rect.x : self.x
      vy = self.viewport ? self.y - self.viewport.oy + self.viewport.rect.y : self.y
      if mx.between?(vx, vx + self.width) &&
        my.between?(vy, vy + self.height)
        if @equip > 1 && my.between?(vy,vy+standard_padding) # Scroll up
          last_eq = @equip
          2.times { cursor_up }
          Sound.play_cursor if last_eq != @equip
          return @delay = 30
        elsif @equip < actor.materia_slots.size - 1 && # Scroll down
              my.between?(vy+self.height-standard_padding,vy+self.height)
          last_eq = @equip
          [actor.materia_slots.size - 1 - @equip,2].min.times { cursor_down }
          Sound.play_cursor if last_eq != @equip
          return @delay = 30
        end
        mx -= vx
        mx -= padding
        my -= vy
        my -= padding
        my += oy
        actor.materia_slots.each do |slot,mats|
          mats.each_with_index do |mat,i|
            next unless i < actor.materia_slots[slot].size
            rect = item_rect(i, slot)
            if mx.between?(rect.x, rect.x + rect.width) &&
               my.between?(rect.y, rect.y + rect.height)
              if @index != i || @equip != slot
                Sound.play_cursor
                @index = i
                @equip = slot
                update_cursor
                call_update_help
                return @delay = 3
              end
            end
          end
        end
      end
      @delay = 3
    end
  end
  
  def item_rect(index, equip)
    rect = Rect.new
    rect.width  = 26
    rect.height = 26
    rect.x  = index * 32 + 27 + base_x - slot_width
    rect.y  = equip * 50 + 24
    rect
  end

  def equip=(equip)
    @equip = equip
    update_cursor
    call_update_help
  end
    
  def update_cursor
    cursor_rect.set(item_rect(@index, @equip))
    self.oy = (equip - equip % 2) * 50
  end
 
  def ensure_cursor_visible
    # Removed! -.-
  end

end
Put it below Victor's Materia script.
And don't forget to remove the old patch.
Thank you @Sixth , this works exactly as desired.

Original thread: https://forums.rpgmakerweb.com/threads/victor-sant-materia-shaz-materia-mouse-addon.90857/