[XP] Help adding a custom command in-battle

I've made a "Status Glossary" which lists all the states in my game that has a rating of 2 or greater. I then have Conditional Branches checking for the name of the index you're currently highlighting which then shows a description of that state in another window. I want this to be an option in the command window in-battle as a quality-of-life improvement for the game.

I've made this using Scene_Item and Window_Item as a foundation, so when I went to find a way to show this in-battle, I went to Scene_Battle 1 and Scene_Battle 3 which handles the actor command stuff. I got far enough to show the option in the command window and to show the windows when selected, but I got stuck because, for some reason, the description doesn't change with the index that is being highlighted and I can't get out of the windows by pressing ESC like I can the others.

Disclaimer: I know it looks messy in-battle (if you choose to put it in a blank project to test), but I already know how to fix the messy-ness of it. I'm just trying to get the two windows to at least function properly.

Here's what I have so far:
Spoiler: My Status Glossary Script
Ruby:
#==============================================================================
# Window_StateDescription
#==============================================================================

class Window_StateDescription < Window_Base
 
 
  def initialize
    super(0, 0, 640, 275)
    self.contents = Bitmap.new(width - 32, height - 32)
    $StateHighlight = 0
    refresh
  end

  def refresh
    self.contents.clear
    self.contents.font.size = 20
    # Same as above.
    @x = 10
    @y = 36
    @Y = -10
    
    #self.contents.font.color = $ColorOptions[1]
    self.contents.font.color = Color.new(255, 255, 255)
    self.contents.font.bold = true
    self.contents.draw_text(@x, 0, 625, 36, "Status Glossary", 1)
    self.contents.draw_text(@x, @y * 6, 625, 36, "All Status Effects are 2 turns unless stated otherwise", 1)
    self.contents.font.color = $ColorOptions[0]

    if $StatusGlossary[$StateHighlight].name == "Stat Buffs"
      self.contents.draw_text(@x, @y, 625, 36, "[Stat Name] = Can be STR, INT, DEX, SPD, HIT, DEF, RES, ATK, or EVA.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "[Stat Name] Buffs gives +20% to mentioned stat.")
      self.contents.draw_text(@x, @y * 3, 625, 36, "[Stat Name] Buffs II (2nd tier) gives +40% to mentioned stat.")
      self.contents.draw_text(@x, @y * 4, 625, 36, "*2nd Tier overwrites 1st Tier and the durations are not combined.")
    end
    if $StatusGlossary[$StateHighlight].name == "Stat Debuffs"
      self.contents.draw_text(@x, @y, 625, 36, "[Stat Name] = Can be STR, INT, DEX, SPD, HIT, DEF, RES, ATK, or EVA.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "[Stat Name] Buffs gives -30% to mentioned stat.")
      self.contents.draw_text(@x, @y * 3, 625, 36, "[Stat Name] Buffs II (2nd tier) gives -60% to mentioned stat.")
      self.contents.draw_text(@x, @y * 4, 625, 36, "*2nd Tier overwrites 1st Tier and the durations are not combined.")
    end
    if $StatusGlossary[$StateHighlight].name == "Heal Debuff"
      self.contents.draw_text(@x, @y, 625, 36, "Reduce healing the target recieves by 50%.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "*Undead are typically immune to this")
    end
    if $StatusGlossary[$StateHighlight].name == "Brand"
      self.contents.draw_text(@x, @y, 625, 36, "Inflicted recieves 20% more damage from all sources, except")
      self.contents.draw_text(@x, @y * 2, 625, 36, "damage-over-time status effects")
    end
    if $StatusGlossary[$StateHighlight].name == "HP Regen"
      self.contents.draw_text(@x, @y, 625, 36, "Target heals equal to 10% of it's Max HP each turn or it's level x 5")
      self.contents.draw_text(@x, @y * 2, 625, 36, "(Whichever is higher).")
      self.contents.draw_text(@x, @y * 3, 625, 36, "*Enemies do not have levels so it's always 10% of their Max HP.")
    end
    if $StatusGlossary[$StateHighlight].name == "Provoke"
      self.contents.draw_text(@x, @y, 625, 36, "Make all targets attack the user.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "*If two allies have this. They will be equally attacked (usually)")
      self.contents.draw_text(@x, @y * 3, 625, 36, "*The Exception is if one has additional factors to their threat")
    end
    if $StatusGlossary[$StateHighlight].name == "Angered"
      self.contents.draw_text(@x, @y, 625, 36, "Make all targets attack the opposite team with a basic attack")
      self.contents.draw_text(@x, @y * 2, 625, 36, "Will disallow targets from using anything but their basic attack")
      self.contents.draw_text(@x, @y * 3, 625, 36, "Grants the target +15% ATK but -15% DEF.")
    end
    if $StatusGlossary[$StateHighlight].name == "Life Enchant"
      self.contents.draw_text(@x, @y, 625, 36, "Add 20% to your ATK. This is treated as Life damage. The effect")
      self.contents.draw_text(@x, @y * 2, 625, 36, "travels between weapons. Only affects melee weapons.")
    end
    if $StatusGlossary[$StateHighlight].name == "CRIT Vulrenability"
      self.contents.draw_text(@x, @y, 625, 36, "Increases chance for target to recieve a Critical Hit by 5%.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "Base Critical Hit: 5% Chance")
    end
    if $StatusGlossary[$StateHighlight].name == "CRI Fail Vulrenability"
      self.contents.draw_text(@x, @y, 625, 36, "Increases chance for target to Critically Fail by 5%.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "Base Critical Hit: 5% Chance")
    end
    if $StatusGlossary[$StateHighlight].name == "Counterattack I"
      self.contents.draw_text(@x, @y, 625, 36, "When attacked, counter with your basic attack at 70% damage.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "Counterattack II: 70% damage, +1 Turn")
      self.contents.draw_text(@x, @y * 3, 625, 36, "Counterattack III: 100% damage, same turns as II")
      self.contents.draw_text(@x, @y * 4, 625, 36, "Counterattack IV: 100% damage, +1 Turn from above")
      self.contents.draw_text(@x, @y * 5, 625, 36, "*May counter with a Skill/Spell instead but that will be specified")
    end
    if $StatusGlossary[$StateHighlight].name == "Reflect"
      self.contents.draw_text(@x, @y, 625, 36, "If dealt damage, attacker takes 30% of the damage.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "Reflect II: attacker takes 60% of the damage.")
      self.contents.draw_text(@x, @y * 3, 625, 36, "Reflect III: attacker takes 100% of the damage.")
      self.contents.draw_text(@x, @y * 4, 625, 36, "*You are still dealt the reflected damage.")
    end
    if $StatusGlossary[$StateHighlight].name == "CRITICAL! STUN"
      self.contents.draw_text(@x, @y, 625, 36, "The inflicted cannot move or evade any attacks until their next turn")
      self.contents.draw_text(@x, @y * 2, 625, 36, "*This is not resistable")
    end
    if $StatusGlossary[$StateHighlight].name == "CRITICAL! FAIL"
      self.contents.draw_text(@x, @y, 625, 36, "The inflicted has these stats reduced by 50% until end of next turn:")
      self.contents.draw_text(@x, @y * 2, 625, 36, "STR, INT, DEX, SPD, HIT, DEF, RES, and ATK.")
      self.contents.draw_text(@x, @y * 3, 625, 36, "*This does effectively reduce your total hit chance by 75% by reducing")
      self.contents.draw_text(@x, @y * 4, 625, 36, "your HIT and another stat affecting your total hit chance.")
      self.contents.draw_text(@x, @y * 5, 625, 36, "*This is not resistable")
    end
    if $StatusGlossary[$StateHighlight].name == "Curse"
      self.contents.draw_text(@x, @y, 625, 36, "The inflicted cannot remove harmful effects, excluding natural means")
      self.contents.draw_text(@x, @y * 2, 625, 36, "The inflicted cannot gain beneficial effects by any means")
    end
    if $StatusGlossary[$StateHighlight].name == "Death Ward"
      self.contents.draw_text(@x, @y, 625, 36, "If inflicted would die, go to 30% HP instead.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "*One can only be affected by Death Ward once per battle.")
    end
    if $StatusGlossary[$StateHighlight].name == "Burn"
      self.contents.draw_text(@x, @y, 625, 36, "Inflicted is dealt fire damage at the start of each of it's turns.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "Fire Damage = 7.5% of Max HP, capped at 100")
      self.contents.draw_text(@x, @y * 3, 625, 36, "*Damage is affected by magical and fire resistances")
      self.contents.draw_text(@x, @y * 4, 625, 36, "*This will remove the Freezing Status.")
    end
    if $StatusGlossary[$StateHighlight].name == "Bleed"
      self.contents.draw_text(@x, @y, 625, 36, "Inflicted is dealt physical damage at the start of each of it's turns.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "Physical Damage = 5% of Max HP, base damage capped at 50")
      self.contents.draw_text(@x, @y * 3, 625, 36, "*Damage is affected by physical resistances and damage boosts on the inflicted.")
      self.contents.draw_text(@x, @y * 4, 625, 36, "Includes but not limited to: DEF Buff, Debuff, and the Brand Status effect.")
      self.contents.draw_text(@x, @y * 5, 625, 36, "*50 is only max base damage. Can be increased by external means, up to 100.")
    end
    if $StatusGlossary[$StateHighlight].name == "Poison"
      self.contents.draw_text(@x, @y, 625, 36, "Inflicted is dealt poison damage at the start of each of it's turns.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "Poison Damage = 5% of Max HP, capped at 50")
      self.contents.draw_text(@x, @y * 3, 625, 36, "*Damage is reduced by the inflicted's (STR - 20) / 2")
      self.contents.draw_text(@x, @y * 4, 625, 36, "*This reduction is capped at 50% of the Poison Damage.")
    end
    if $StatusGlossary[$StateHighlight].name == "Seal"
      self.contents.draw_text(@x, @y, 625, 36, "Inflicted cannot use Spells.")
    end
    if $StatusGlossary[$StateHighlight].name == "Sleep"
      self.contents.draw_text(@x, @y, 625, 36, "Inflicted cannot evade or move but is no longer inflicted when attacked")
    end
    if $StatusGlossary[$StateHighlight].name == "Freezing"
      self.contents.draw_text(@x, @y, 625, 36, "Inflicted has their Skills/Spells cost 30% more than usual.")
      self.contents.draw_text(@x, @y * 2, 625, 36, "*This will remove Burn status.")
    end

    self.contents.font.size = 16
  end
end

#==============================================================================
#Window_States
#==============================================================================

class Window_States < Window_Selectable
 
  def initialize
    super(0, 275, 640, 240)
    @column_max = 3
    refresh
    self.index = 0
  end
 
  #--------------------------------------------------------------------------
  # * Get State
  #--------------------------------------------------------------------------
  def state
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    $StatusGlossary = []
    for i in 1...$data_states.size
      if $data_states[i].name != "" and not $data_states[i].rating <= 1
        @data.push($data_states[i])
      end
      @data = @data.sort{|a, b| a.name <=> b.name }
      $StatusGlossary = @data
    end

    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
 
  def update_index
    $StateHighlight = self.index
  end
 
 
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    state = @data[index]
    self.contents.font.color = normal_color
    self.contents.font.bold = true
    y = (index / 3 * 32)
    x = (index % 3 * (107 + 55 + 40))
    self.contents.font.size = 20
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(x + 28, y, 212, 32, state.name, 0)
  end
 
end


#==============================================================================
# Scene_State
#==============================================================================

class Scene_State
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window, item window
    Font.default_bold = true
    @item_window = Window_States.new
    @desc_window = Window_StateDescription.new
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @desc_window.dispose
    @item_window.dispose
    Font.default_bold = false
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @item_window.update
    # If item window is active: call update_item
    if @item_window.active
      update_item
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_item
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(0)
      return
    end
    
    if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT) or Input.repeat?(Input::DOWN) or Input.repeat?(Input::UP)
      @item_window.update_index
      @desc_window.refresh
    end
    
  end
 
end

Spoiler: What I did so far
I added the following to Scene_Battle 1 starting at line 25
Ruby:
# Make actor command window
    s1 = $data_system.words.attack
    s2 = $data_system.words.skill
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    s5 = "Glossary" #<= Added this
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5]) #<= Added "s5"

Then, I added the following to Scene_Battle 3 in the "update_phase3_basic_command" method where it says when 1, when 2, etc, and i just added Status Glossary following that pattern in the method.
Ruby:
when 4  # status glossary
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Start item selection
        start_status_select

Following how items were coded in Scene_Battle 3, I used that as a foundation and made the two following methods at the bottom with the rest of the "start_x_select" and "end_x_select"
Ruby:
#--------------------------------------------------------------------------
  # * Start status Selection
  #--------------------------------------------------------------------------
  def start_status_select
    # Make item window
    @status_window = Window_States.new
    @desc_window = Window_StateDescription.new
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end
  #--------------------------------------------------------------------------
  # * End status Selection
  #--------------------------------------------------------------------------
  def end_status_select
    # Dispose of item window
    @status_window.dispose
    @status_window = nil
    @desc_window.dispose
    @desc_window = nil
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
  end

Lastly, I added, following how items were coded, the following code to have it show up when you select the command. I understand that I probably did something wrong here, but I don't know what, and I definitely don't know why it can't cancel out when I press ESC.
Ruby:
#--------------------------------------------------------------------------
  # * Frame Update (actor command phase : status selection)
  #--------------------------------------------------------------------------
  def update_phase3_status_select
    # Make item window visible
    @status_window.visible = true
    @desc_window.visible = true
    # Update item window
    @status_window.update
    @desc_window.refresh
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # End item selection
      end_status_select
      return
    end
    
    if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT) or Input.repeat?(Input::DOWN) or Input.repeat?(Input::UP)
      @status_window.update_index
      @desc_window.refresh
    end
    
  end
Pay attention to this specific method for a while.

Ruby:
class Scene_Battle
  # Lots of Code Lines I skipped on purpose
  def update_phase3
    # If enemy arrow is enabled
    if @enemy_arrow != nil
      update_phase3_enemy_select
    # If actor arrow is enabled
    elsif @actor_arrow != nil
      update_phase3_actor_select
    # If skill window is enabled
    elsif @skill_window != nil
      update_phase3_skill_select
    # If item window is enabled
    elsif @item_window != nil
      update_phase3_item_select
    # If actor command window is enabled
    elsif @actor_command_window.active
      update_phase3_basic_command
    end
  end
end

There is also another issue that should be handled at once and it is the reuse of @status_window to hold a new type of window class object. You better change its name right away to prevent you from getting headaches in the nearby future.

Do you notice that something is missing there?
Pay attention to this specific method for a while.

Ruby:
class Scene_Battle
  # Lots of Code Lines I skipped on purpose
  def update_phase3
    # If enemy arrow is enabled
    if @enemy_arrow != nil
      update_phase3_enemy_select
    # If actor arrow is enabled
    elsif @actor_arrow != nil
      update_phase3_actor_select
    # If skill window is enabled
    elsif @skill_window != nil
      update_phase3_skill_select
    # If item window is enabled
    elsif @item_window != nil
      update_phase3_item_select
    # If actor command window is enabled
    elsif @actor_command_window.active
      update_phase3_basic_command
    end
  end
end

There is also another issue that should be handled at once and it is the reuse of @status_window to hold a new type of window class object. You better change its name right away to prevent you from getting headaches in the nearby future.

Do you notice that something is missing there?
Sure, renamed it to @status2_window though would it not matter since it's a local variable in an entierly different scene (Scene_Battle) where the other is in Scene_Status? Regardless, that's one of the changes I did in the past (did the elsif @status_window != nil), but when I do that, the cursor just freezes, and I still cannot cancel out of the window. By the way, I assumed this is what you mean:

Ruby:
def update_phase3
    # If enemy arrow is enabled
    if @enemy_arrow != nil
      update_phase3_enemy_select
    # If actor arrow is enabled
    elsif @actor_arrow != nil
      update_phase3_actor_select
    # If skill window is enabled
    elsif @skill_window != nil
      update_phase3_skill_select
    # If item window is enabled
    elsif @item_window != nil
      update_phase3_item_select
    elsif @status2_window != nil #<= I assume you mean this
      update_phase3_status_select
    # If actor command window is enabled
    elsif @actor_command_window.active
      update_phase3_basic_command
    end
  end

EDIT: So, I got the cursor to work again. It appears renaming @status_window to @status2_window causes the cursor to freeze. After naming it back, I still can't back out and the description isn't changing with the highlighted index.
That was the first step and the second one would be to delete this line the first time it shows up in the update_phase3_status_select method.

Ruby:
@desc_window.refresh

That's the culprit. You don't need it to be refreshed every single frame.

I can just watch a single description being displayed on screen, namely Sleep's.
That was the first step and the second one would be to delete this line the first time it shows up in the update_phase3_status_select method.

Ruby:
@desc_window.refresh

That's the culprit. You don't need it to be refreshed every single frame.
Culprit of? I still can't cancel. I can move the cursor for it seems it was freezing when I renamed @status_window to something else.
This is the modified version of your script.

Ruby:
class Scene_Battle
  def main
    # Initialize each kind of temporary battle data
    $game_temp.in_battle = true
    $game_temp.battle_turn = 0
    $game_temp.battle_event_flags.clear
    $game_temp.battle_abort = false
    $game_temp.battle_main_phase = false
    $game_temp.battleback_name = $game_map.battleback_name
    $game_temp.forcing_battler = nil
    # Initialize battle event interpreter
    $game_system.battle_interpreter.setup(nil, 0)
    # Prepare troop
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    # Make actor command window
    s1 = $data_system.words.attack
    s2 = $data_system.words.skill
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    s5 = "Glossary" #<= Added this
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
    @actor_command_window.y = 128
    @actor_command_window.back_opacity = 160
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # Make other windows
    @party_command_window = Window_PartyCommand.new
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.visible = false
    @status_window = Window_BattleStatus.new
    @message_window = Window_Message.new
    # Make sprite set
    @spriteset = Spriteset_Battle.new
    # Initialize wait count
    @wait_count = 0
    # Execute transition
    if $data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(40, "Graphics/Transitions/" +
        $data_system.battle_transition)
    end
    # Start pre-battle phase
    start_phase1
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Refresh map
    $game_map.refresh
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @actor_command_window.dispose
    @party_command_window.dispose
    @help_window.dispose
    @status_window.dispose
    @message_window.dispose
    if @skill_window != nil
      @skill_window.dispose
    end
    if @item_window != nil
      @item_window.dispose
    end
    if @result_window != nil
      @result_window.dispose
    end
    # Dispose of sprite set
    @spriteset.dispose
    # If switching to title screen
    if $scene.is_a?(Scene_Title)
      # Fade out screen
      Graphics.transition
      Graphics.freeze
    end
    # If switching from battle test to any screen other than game over screen
    if $BTEST and not $scene.is_a?(Scene_Gameover)
      $scene = nil
    end
  end

  def update_phase3
    # If enemy arrow is enabled
    if @enemy_arrow != nil
      update_phase3_enemy_select
    # If actor arrow is enabled
    elsif @actor_arrow != nil
      update_phase3_actor_select
    # If skill window is enabled
    elsif @skill_window != nil
      update_phase3_skill_select
    # If item window is enabled
    elsif @item_window != nil
      update_phase3_item_select
    # If actor command window is enabled
    elsif @actor_command_window.active
      update_phase3_basic_command
    elsif @desc_window.active
      update_phase3_status_select
    end
  end

  def update_phase3_basic_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Go to command input for previous actor
      phase3_prior_actor
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by actor command window cursor position
      case @actor_command_window.index
      when 0  # attack
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set action
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 0
        # Start enemy selection
        start_enemy_select
      when 1  # skill
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set action
        @active_battler.current_action.kind = 1
        # Start skill selection
        start_skill_select
      when 2  # guard
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set action
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 1
        # Go to command input for next actor
        phase3_next_actor
      when 3  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set action
        @active_battler.current_action.kind = 2
        # Start item selection
        start_item_select
      when 4  # status glossary
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Start item selection
        start_status_select
      end
    end
  end

  def start_status_select
    # Make item window
    @state_window = Window_States.new
    @state_window.active = true
    @state_window.visible = true
    @status_window.visible = false
    @state_window.z += 5000
    @desc_window = Window_StateDescription.new
    @desc_window.visible = true
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end

  def end_status_select
    # Dispose of item window
    @state_window.active = false
    @state_window.visible = false
    @state_window.dispose
    @state_window = nil
    @desc_window.dispose
    @desc_window = nil
    @status_window.visible = true
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
  end

  def update_phase3_status_select
    # Update item window
    @state_window.update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # End item selection
      end_status_select
      return
    end
    if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT) or
       Input.repeat?(Input::DOWN) or Input.repeat?(Input::UP)
      @state_window.update_index
      @desc_window.refresh
    end
  end
end

In my case it runs smoothly.
This is the modified version of your script.

Ruby:
class Scene_Battle
  def main
    # Initialize each kind of temporary battle data
    $game_temp.in_battle = true
    $game_temp.battle_turn = 0
    $game_temp.battle_event_flags.clear
    $game_temp.battle_abort = false
    $game_temp.battle_main_phase = false
    $game_temp.battleback_name = $game_map.battleback_name
    $game_temp.forcing_battler = nil
    # Initialize battle event interpreter
    $game_system.battle_interpreter.setup(nil, 0)
    # Prepare troop
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    # Make actor command window
    s1 = $data_system.words.attack
    s2 = $data_system.words.skill
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    s5 = "Glossary" #<= Added this
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
    @actor_command_window.y = 128
    @actor_command_window.back_opacity = 160
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # Make other windows
    @party_command_window = Window_PartyCommand.new
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.visible = false
    @status_window = Window_BattleStatus.new
    @message_window = Window_Message.new
    # Make sprite set
    @spriteset = Spriteset_Battle.new
    # Initialize wait count
    @wait_count = 0
    # Execute transition
    if $data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(40, "Graphics/Transitions/" +
        $data_system.battle_transition)
    end
    # Start pre-battle phase
    start_phase1
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Refresh map
    $game_map.refresh
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @actor_command_window.dispose
    @party_command_window.dispose
    @help_window.dispose
    @status_window.dispose
    @message_window.dispose
    if @skill_window != nil
      @skill_window.dispose
    end
    if @item_window != nil
      @item_window.dispose
    end
    if @result_window != nil
      @result_window.dispose
    end
    # Dispose of sprite set
    @spriteset.dispose
    # If switching to title screen
    if $scene.is_a?(Scene_Title)
      # Fade out screen
      Graphics.transition
      Graphics.freeze
    end
    # If switching from battle test to any screen other than game over screen
    if $BTEST and not $scene.is_a?(Scene_Gameover)
      $scene = nil
    end
  end

  def update_phase3
    # If enemy arrow is enabled
    if @enemy_arrow != nil
      update_phase3_enemy_select
    # If actor arrow is enabled
    elsif @actor_arrow != nil
      update_phase3_actor_select
    # If skill window is enabled
    elsif @skill_window != nil
      update_phase3_skill_select
    # If item window is enabled
    elsif @item_window != nil
      update_phase3_item_select
    # If actor command window is enabled
    elsif @actor_command_window.active
      update_phase3_basic_command
    elsif @desc_window.active
      update_phase3_status_select
    end
  end

  def update_phase3_basic_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Go to command input for previous actor
      phase3_prior_actor
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by actor command window cursor position
      case @actor_command_window.index
      when 0  # attack
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set action
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 0
        # Start enemy selection
        start_enemy_select
      when 1  # skill
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set action
        @active_battler.current_action.kind = 1
        # Start skill selection
        start_skill_select
      when 2  # guard
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set action
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 1
        # Go to command input for next actor
        phase3_next_actor
      when 3  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set action
        @active_battler.current_action.kind = 2
        # Start item selection
        start_item_select
      when 4  # status glossary
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Start item selection
        start_status_select
      end
    end
  end

  def start_status_select
    # Make item window
    @state_window = Window_States.new
    @state_window.active = true
    @state_window.visible = true
    @status_window.visible = false
    @state_window.z += 5000
    @desc_window = Window_StateDescription.new
    @desc_window.visible = true
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end

  def end_status_select
    # Dispose of item window
    @state_window.active = false
    @state_window.visible = false
    @state_window.dispose
    @state_window = nil
    @desc_window.dispose
    @desc_window = nil
    @status_window.visible = true
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
  end

  def update_phase3_status_select
    # Update item window
    @state_window.update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # End item selection
      end_status_select
      return
    end
    if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT) or
       Input.repeat?(Input::DOWN) or Input.repeat?(Input::UP)
      @state_window.update_index
      @desc_window.refresh
    end
  end
end

In my case it runs smoothly.
I found the issue, and i feel dumb for not realizing it. It was an incompatibility with my ATB battle script. Reason I feel dumb is because I just remembered I had this exact same issue when I added an equip option in the actor command. When I opened the equip screen, it would just lock up.

Due to this, a scripter helped me by adding a method to the equip script to overwrite the update_phase3 method which, as you can now guess, overwrited what I changed in Scene_Battle.

Regardless, thank you! I was sitting here like "Comparing ours, mine should still work but just be leaning on the low FPS side." Good to know I more or less did things correctly with only minor hiccups as you mentioned. You also did things that was better than what I was thinking on doing (on cleaning it up for the player). I was planning on making variables and editing other things and you made it very simple by just making things not visible lol. I also never thought to just increase the height of the command window to remove the scrolling. Welp, you live and learn!

After looking at your altered script, you made some changes that I wanted to ask questions about:
1. On line 109 (elsif @desc_window.active), you chose to use active instead of the != nil. How come? I needed to change it to != nil to make everything compatible, but I'm curious what made you go with this.

2. When it comes to making the windows visible, I noticed you did it in start method and not in the update_phase3 method like the default ones. How come?

3. You cut out the methods you wasn't planning to overwrite at all. I assume the reason is because it's probably better for script compatibility in case something else overwrites it (and your script placement may make things wonky) and to make scripts just smaller and more manageable. is that correct? I only learned very recently you could do this before making this script and didn't think to do it here. Wish I knew that when I did my level up script so long ago (2034 lines 😩)
1. Those conditions are defined as the only way to handle existing windows or arrows and nothing else because the script doesn't include any exceptions by default. That means that you won't get there by chance or by mistake. In that case both solutions would have worked fine there. It would be different if and only if another test would be run after that condition had failed like some armor or weapon exchange or anything else one could come up with.

2. Not few of the default methods offer bad examples of how to code stuff to be run in the worst moment ever. All those visible methods should have been handled in their respective start and end methods. If the window will remain visible after a single visible = true call, why would anybody repeat that call over and over again. It's possible but it's a terrible example, nonetheless. One should skip making useless calls inside those update methods. And never reprocess and redraw everything every single frame! Only maps should ever undergo such processes.

3. Got nothing to add here.

Original thread: https://forums.rpgmakerweb.com/threads/xp-help-adding-a-custom-command-in-battle.153648/