Preface:
I would highly recommend not handling a Window this way (as a instance variable within an instance of Game_Interpreter). Game_Interpreter objects are serialized into the save file, and this cannot happen if there is a Window object in an instance variable. You need to be
absolutely sure you have both disposed all windows and nullified the containing variables before any kind of control is given to the player, or the scene is switched, or else the player will not be able to save the game. The initial example does neither - even if the window in the @random_window were disposed, you have left no path to get at the window in the instance variable in THAT window since it doesn't automatically dispose and you didn't leave an accessor. You should avoid nested window handling like this (window within a window) unless your second window specifically needs continual access to properties of the first; in this case, it doesn't, and the command window portion is encapsulated when it is the far more importation window of the two. Your handlers are also pointing back to the methods within window itself - and they both do the same thing.
However, all that being said, this can still be done. First, trim the bloat out of your classes (I kept your naming conventions, but those could also use work):
Spoiler
class Random_Window_One < Window_Base def initialize() super(0, 0, Graphics.width, 200) endendclass Random_Command_Window < Window_Command def initialize super(0, 200) end def start activate select(0) end def make_command_list add_command("Option One", :one) add_command("Option Two", :two) endend
In your event, create the windows and put them in instance variables*:
@rw1 = Random_Window_One.new@rcw = Random_Command_Window.new@rcw.set_handler
:)ok, proc { @my_var = @rcw.index } )@rcw.start*This should only be done in the main interpreter. Using a parallel process may cause you to lose your path to the window, which would be bad for reasons explained aboveThen, you need to loop and update at the bare minimum the command window. You also need a one frame wait in this loop so that the interpreter will yield back to the Scene, so the normal Scene update methods can take place (failing to do so will cause the loop to hang, since script commands do not cause the interpreter to yield, they will just continue through the local loop forever without allowing Graphics and Input to update). Since the interpreter is running (we are in the loop), the player will not be able to move or open the menu.
Next, you need to conditionally break the loop. As you can see above, I have set the
:ok handler to set an instance variable @my_var (again, terrible naming conventions, use something more appropriate) to a certain value. When the
:ok handle is triggered, this proc will be activated and the variable will be set. So the condition for loop break can be that this variable is not nil. You can set separate handlers for each command, the
:ok one will handle any one not specifically given a handler.
As soon as you break the loop, you
must dispose your windows and nullify their variables. For good measure, also nullify the other variable you have used, otherwise it will persist between event calls that use the main interpreter (you want the event to be reusable). This way, the next time you call this event, it will work normally.
Throw it all together, you should have something like this:
