Bug Ace Equip Engine

Hello. I found a small bug with the script Equipment Requirements from Fomar, but modified to have an interface. When I navigate inside Equipment Menu, if I push in L or R buttons and I back in the main menu, my cursor moved in another character. Normally, these buttons are used to move from one character to another but inside th Equipment Menu, it's not possible. I would like the cursor don't move when I back in the main menu. Can you help me please ? The script is below.
Up
Up
The problem is not with the script from Yanfly, but with the script from Fomar which has been modified to integrate an interface to see the conditions for wearing equipments.


As the script has been modified, I give the link below (look at lines 198 and 201) :

Code:
=begin
Equipment Requirements
by Fomar0153
modified by Zouzaka
Version 1.3
----------------------
Notes
----------------------
Adds a level requirement to equipment.
----------------------
Instructions
----------------------
Notetag the weapons/armors like so:
<levelreq x>
<mhpreq x>
<mmpreq x>
<atkreq x>
<defreq x>
<matreq x>
<mdfreq x>
<agireq x>
<lukreq x>
<switchreq x>
<variablereq x,y>
<wepreq x>
<armreq x>
----------------------
Change Log
----------------------
1.0 -> 1.1 Added stat requirements
          Changed script name from Equipment Level Requirements
          to just Equipment Requirements
1.1 -> 1.2 Added switch and other equipment requirements
1.2 -> 1.3 Ajout D'une Window qui affiche les Conditions requises
          Réduit le script de base de plus de 50 lignes
1.3 -> 1.4 Optimisation et resolution de bug
----------------------
Known bugs
----------------------
None
=end
  #--------------------------------------------------------------------------
  # ● If set to true then it compares the requirement with the actor's base 
  #  stat rather than their current.
  #--------------------------------------------------------------------------
EQUIPREQ_USE_BASE_STAT = true
  #--------------------------------------------------------------------------
  # ● Vocab for switch's 
  #  every switch_id in a different line
  #--------------------------------------------------------------------------
 
Switch_Vocab = {
# Switch_ID => "Vocab",
2 => "Visiter la Campagne",
}
  #--------------------------------------------------------------------------
  # ● Vocab for variables 
  #  every variable_id in a different line
  #--------------------------------------------------------------------------
 
Variable_Vocab = {
# Variable_ID => "Vocab",
2 => "Nombre de pierres à casser",
}
 
 
class Game_Actor
  def optimize_equipments
    clear_equipments
    equip_slots.size.times do |i|
      next if !equip_change_ok?(i)
      items = $game_party.equip_items.select do |item|
        item.etype_id == equip_slots[i] &&
        equippable?(item) && item.performance >= 0 && reqstate?(item)
      end
      change_equip(i, items.max_by {|item| item.performance })
    end
  end
  def reqstate?(item)
    unless item == nil
      return false if level < item.levelreq
      return false if reqstat(0) < item.mhpreq
      return false if reqstat(1) < item.mmpreq
      return false if reqstat(2) < item.atkreq
      return false if reqstat(3) < item.defreq
      return false if reqstat(4) < item.matreq
      return false if reqstat(5) < item.mdfreq
      return false if reqstat(6) < item.agireq
      return false if reqstat(7) < item.lukreq
      if item.switchreq > 0
        return false unless $game_switches[item.switchreq]
      end
      if item.variablereq != 0
        return false unless $game_variables[item.variablereq[0]] < item.variablereq[1]
      end
      if item.wepreq > 0
        e = []
        for equip in equips
          e.push(equip.id) if equip.class == RPG::Weapon
        end
        return false unless e.include?(item.wepreq)
      end
      if item.armreq > 0
        e = []
        for equip in equips
          e.push(equip.id) if equip.class == RPG::Armor
        end
        return false unless e.include?(item.armreq)
      end
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● New Method
  #--------------------------------------------------------------------------
  def reqstat(id)
    EQUIPREQ_USE_BASE_STAT ? param_base(id) : param(id)
  end
end
class Window_EquipItem
  #--------------------------------------------------------------------------
  # ● Check the requirements
  #--------------------------------------------------------------------------
  def enable?(item)
    return @actor.reqstate?(item)
  end
end
module RPG
  #--------------------------------------------------------------------------
  # ● Equip Item is inherited by both Weapon and Armor
  #--------------------------------------------------------------------------
  class EquipItem
    def variablereq
      self.note =~ /<variablereq (.*),(.*)>/i ? [$1.to_i,$2.to_i] : 0
    end
    def levelreq
      self.note =~ /<levelreq (.*)>/i ? $1.to_i : 0
    end
    def mhpreq
      self.note =~ /<mhpreq (.*)>/i ? $1.to_i : 0
    end
    def mmpreq
      self.note =~ /<mmpreq (.*)>/i ? $1.to_i : 0
    end
    def atkreq
      self.note =~ /<atkreq (.*)>/i ? $1.to_i : 0
    end
    def defreq
      self.note =~ /<defreq (.*)>/i ? $1.to_i : 0
    end
    def matreq
      self.note =~ /<matreq (.*)>/i ? $1.to_i : 0
    end
    def mdfreq
      self.note =~ /<mdfreq (.*)>/i ? $1.to_i : 0
    end
    def agireq
      self.note =~ /<agireq (.*)>/i ? $1.to_i : 0
    end
    def lukreq
      self.note =~ /<lukreq (.*)>/i ? $1.to_i : 0
    end
    def switchreq
      self.note =~ /<switchreq (.*)>/i ? $1.to_i : 0
    end
    def wepreq
      self.note =~ /<wepreq (.*)>/i ? $1.to_i : 0
    end
    def armreq
      self.note =~ /<armreq (.*)>/i ? $1.to_i : 0
    end
  end
end
class Window_Requirement < Window_Base
  def initialize(x, y)
    super(x, y, Graphics.width/2, Graphics.height)
    self.openness = 0
    self.z = 250
    @item = nil
    @actor = nil
    refresh
  end
  def reqstat(id)
    EQUIPREQ_USE_BASE_STAT ? @actor.param_base(id) : @actor.param(id)
  end
  def item ; return @item ; end
  def item=(item)
    @item = item
    refresh
  end
  def actor ; return @actor ; end
  def actor=(actor)
    @actor = actor
    refresh
  end
  def update
    super
    if Input.trigger?(:R)
      @actor = $game_party.menu_actor_next
      refresh
    elsif Input.trigger?(:L)
      @actor = $game_party.menu_actor_prev
      refresh
    end
  end
  def refresh
    contents.clear
    @req = ["item.levelreq","item.mhpreq","item.mmpreq","item.atkreq","item.defreq","item.matreq","item.mdfreq","item.agireq","item.lukreq"]#,"item.wepreq","item.armreq"]
    @vocab_req = [Vocab.level,Vocab.param(0),Vocab.param(1),Vocab.param(2),Vocab.param(3),Vocab.param(4),Vocab.param(5),Vocab.param(6),Vocab.param(7)]#,Vocab.weapon,Vocab.armor]
    @req_condition = ["@actor.level","reqstat(0)","reqstat(1)","reqstat(2)","reqstat(3)","reqstat(4)","reqstat(5)","reqstat(6)","reqstat(7)"]
    @t = 2
    change_color(normal_color)
    draw_text(contents.width/8, 0, contents.width, line_height, "Conditions requises")
    @req.each do |req|
      if item != nil && eval(req) != 0 && actor != nil
        eval(@req_condition[@req.index(req)]) < eval(req) ? change_color(text_color(2)) : change_color(normal_color)
        draw_text(0, line_height*@t, contents.width, line_height, @vocab_req[@req.index(req)]+" requis : "+eval(req).to_s)
        @t += 1
      end
    end
    change_color(normal_color)
    if item != nil && item.wepreq != 0 && actor != nil
      e = []
      for equip in @actor.equips 
        if equip.class == RPG::Weapon
          e.push(equip.id)
        end
      end
      change_color(text_color(2)) unless e.include?(item.wepreq)
      draw_text(0, line_height*@t, contents.width, line_height, "Arme requise : "+$data_weapons[item.wepreq].name)
      @t += 1
    end
    change_color(normal_color)
    if item != nil && item.armreq != 0 && actor != nil
      e = []
      for equip in @actor.equips
        e.push(equip.id) if equip.class == RPG::Armor
      end
      change_color(text_color(2)) unless e.include?(item.armreq)
      draw_text(0, line_height*(@t), contents.width, line_height, "Armure requise : "+$data_armors[item.armreq].name)
      @t += 1
    end
    if item && item.switchreq != 0
      $game_switches[item.switchreq] ? change_color(normal_color) : change_color(text_color(2))
      draw_text(0, line_height*(@t), contents.width, line_height, Switch_Vocab[item.switchreq])
      @t += 1
    end
    if item && item.variablereq != 0
      $game_variables[item.variablereq[0]] >= item.variablereq[1] ? change_color(normal_color) : change_color(text_color(2))
      draw_text(0, line_height*(@t), contents.width, line_height, Variable_Vocab[item.variablereq[0]]+" "+$game_variables[item.variablereq[0]].to_s+"/"+item.variablereq[1].to_s)
    end
    change_color(normal_color)
    draw_text(0, contents.height-line_height*3, contents.width, line_height, "Prec.(Q) | Suiv.(W)",1)
    draw_text(0, contents.height-line_height*2, contents.width, line_height, "Personnage Actuel",1)
    draw_text(0, contents.height-line_height, contents.width, line_height, @actor.name,1) if @actor
  end
end
 
#~ #==============================================================================
#~ # ** Scene_Equip
#~ #------------------------------------------------------------------------------
#~ #  This class performs the equipment screen processing.
#~ #==============================================================================
 
class Scene_Equip
  alias :old_start :start
  def start
    old_start
    @window_req = Window_Requirement.new(Graphics.width/4,0)
  end
  alias :old_update :update
  def update
    old_update
    if Input.trigger?(:CTRL)
      if @window_req.openness == 0 && @item_window.active && @item_window.item != nil
        @window_req.item=@item_window.item
        @window_req.actor= @actor
        @background = Sprite.new
        @background.z = 200
        @background.bitmap = Bitmap.new(Graphics.width, Graphics.height)
        @background.bitmap.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0, 0, 0,128))
        @window_req.open
        @item_window.deactivate
      elsif @window_req.openness == 255
        @background.dispose if @background
        @window_req.close
        @item_window.activate
      end
    end
  end
end
class Scene_Item < Scene_ItemBase
  alias :old_start :start
  def start
    old_start
    @window_req = Window_Requirement.new(Graphics.width/4,0)
  end
  alias :old_update :update
  def update
    old_update
    if Input.trigger?(:CTRL)
      if @window_req.openness == 0 && (@item_window.item.class == RPG::Weapon || @item_window.item.class == RPG::Armor)
        @window_req.item=@item_window.item
        @window_req.actor= @actor
        @background = Sprite.new
        @background.z = 200
        @background.bitmap = Bitmap.new(Graphics.width, Graphics.height)
        @background.bitmap.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0, 0, 0,128))
        @window_req.open
        @item_window.deactivate
      elsif @window_req.openness == 255
        @background.dispose if @background
        @window_req.close
        @item_window.activate
      end
    end
  end
end
This topic can be closed. I modified def update and deleted :L and :R.

Original thread: https://forums.rpgmakerweb.com/threads/bug-ace-equip-engine.55405/