Refreshing the command window

Quick question. I am trying to refresh a command list and I've run into a jam. This are the methods I am currently using.

Spoiler
Code:
  #--------------------------------------------------------------------------  # * Make Command List  #--------------------------------------------------------------------------  def make_command_list(index = 0)    make_commands(index)  end   #--------------------------------------------------------------------------  # * Make Commands  #--------------------------------------------------------------------------  def make_commands(index)    case index    when 0      @actor.current_classes.each_index { |i|        add_command($data_classes[@actor.current_classes[i]].name, $data_classes[@actor.current_classes[i]].name.to_sym)      }    when 1      @actor.available_classes.each_index { |i|        add_command($data_classes[@actor.available_classes[i]].name, $data_classes[@actor.available_classes[i]].name.to_sym)      }    end  end   #--------------------------------------------------------------------------  # * Refresh List  #--------------------------------------------------------------------------  def refresh_list(index)    contents.clear    make_command_list(index)  end 
what's the jam?

btw, refreshing the command windows uses the clear_command_list to clear the command list first

Code:
def refresh    clear_command_list    make_command_list    create_contents    super  end
now since you didn't run the clear_command_list, every time you run the make_command_list it means you're adding up the new commands to the list of previous commands... and that would result to the old commands being there + the new commands
lol, Yeah I guess that helps huh?

When it refreshes the commands stay cleared and the list becomes empty when it should not.
because you cleared contents, but didn't run the create_contents... and take note of my previous post about adding the commands

btw, you don't need the contents.clear since the create_contents disposes the contents first...

so basically your refresh list should be something like

def refresh_list(index) clear_command_list make_command_list(index) create_contents superendbtw, where do you call the refresh_list method from?PS: It's always a good thing to look first at how the default scripts handle these things... 🙂
Thanks Adiktuzmiko that helped a lot!
so is it okay now?
Yes, Thank you! 😀

Original thread: https://forums.rpgmakerweb.com/threads/refreshing-the-command-window.19850/