Remove window command after use.

I have a custom scene where the player chooses two of nine factions to ally with using a command window. I have a command window that displays the factions as well as some information about them (A different window is used to finalize the choice). I want to use the same window both times, and just remove the previously selected option. My first idea was to refresh the window and redraw the commands, skipping over the one that was previously selected, as determined by $game_variable 14:

@command_window = Window_Factions.new(0,0) @command_window.width = 200 @command_window.refresh if $game_variables[14] != 1 @command_window.set_handler🙂Guild, method🙂Ally_Guild)) end if $game_variables[14] != 2 @command_window.set_handler🙂Sacceris, method🙂Ally_Sacceris)) end if $game_variables[14] != 3 @command_window.set_handler🙂Isendra, method🙂Ally_Isendra)) end if $game_variables[14] != 4 @command_window.set_handler🙂Ashther, method🙂Ally_Ashther)) end if $game_variables[14] != 5 @command_window.set_handler🙂Champions, method🙂Ally_Champions)) end if $game_variables[14] != 6 @command_window.set_handler🙂Fraternity, method🙂Ally_Fraternity)) end if $game_variables[14] != 7 @command_window.set_handler🙂Ettaia, method🙂Ally_Ettaia)) end if $game_variables[14] != 8 @command_window.set_handler🙂Sovereign, method🙂Ally_Sovereign)) end if $game_variables[14] != 9 @command_window.set_handler🙂Guardians, method🙂Ally_Guardians)) end @display_window = Window_Base.new(200, 0, Graphics.width - 200, Graphics.height)This doesn't seem to work, however. How do I remove a command, or otherwise more completely redraw a window?
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


Please explain what "doesn't seem to work" means. What DOES it do?
The drawing of the commands is not made within the scene itself. It is made within the command window.


You only removed the methods running upon confirming a choice, but you did not remove the creation of the command button itself. That has to be made in your window class.


If you are using the default command button creation, that should be in the 'make_command_list' method.


However, don't use a global variable for a static condition check. It is not necessary at all. Create your own ones within the class itself, and forget about $game_variables regarding these checks. If you would use an array/hash to configure the available commands somewhere, and an array/hash to check which ones were already selected, your code above could be made with only around 10 lines, if not less.
If I understood it correctly you want to remove an option from the available options. The thing that you're doing in your snippet above is merely deactivating their capability of calling a method when you select them, since you're trying to prevent the script from setting set_handler. The option will remain in the choices to be seen but you can't select it.

You'll have to update make_command_list in order to have the unwanted option to disappear. Otherwise it'll stay there.

Though I recommend you to not use global variables for this (and use class variables instead) I'll stick with your way for now:

def make_command_listadd_command("Faction 1", :faction_1) unless $game_variables[14] == xadd_command("Faction 2", :faction_2) unless $game_variables[14] == yadd_command("Faction 3", :faction_3) unless $game_variables[14] == z# Put in as many as you have...end # make_command_list
That's a bit tedious but it doesn't require you to write advanced ruby stuff. You would have to accordingly set $game_variables[14] after you called the option you want to disappear. After that you'll call refresh so that your changes will be made.

Just make sure that the command list is properly reset (@list = []) before make_command_list is run or otherwise you'll see no difference. For this you can simply call clear_command_list.

clear_command_listmake_command_listEdit: Too late, I guess.
Alistair understood my question best, but Sixth pointed me in the right direction. Thanks guys.

I wanted the selected faction to remove itself from the listing, so that it coudln't be chosen the second time around. I was looking at the problem all wrong, which is why I couldn't figure out why nothing was changing; forgetting that setting handlers was step 2 of the process after the command was already created. I have a custom window script that creates the command, and then the handler is set in the scene script. (This is probably bad protocol, but It must have made sense to me at the time). I had to go back to the window script to make the commands appear, and now it's doing what I wanted it to.

It's been a while since I looked at this stuff.

Original thread: https://forums.rpgmakerweb.com/threads/remove-window-command-after-use.39587/