How do wait for input in script menu? (Check post tag!!!)

I want to make it, so the main menu waits for a button input before showing the command menu. What’s the script call for that?

It’s hard to explain which is the specific thing to wait for input, but um did a custom script for it.

Basically, first break the problem into pieces.

  • We need to start by making the command window start hidden. For this I’ll be using the openness property, because this lets you also have a quick animation for almost no cost.
  • Then we need to check for input presses. When the corresponding button is pressed, the window is “opened”.

I also made it so you can exit the menu with X (Cancel) since that functionality usually depends on the window, and in this case it would not do it and you’d be stuck in the menu until you open the window and then press X to close the menu.

Here’s the full script.

class Window_MenuCommand < Window_Command
  alias oz_waitforopen_initialize initialize
  def initialize
    oz_waitforopen_initialize
    # Start the window closed
    self.openness = 0
  end
end

class Scene_Menu < Scene_MenuBase
  alias oz_waitforopen_update update
  def update
    oz_waitforopen_update
    # Check if window is closed
    if @command_window.close?
      # Open if Z is pressed
      if Input.trigger?(:C)
        @command_window.open
      # Close menu if X is pressed
      elsif Input.trigger?(:B)
        return_scene
      end
    end
  end
end

The specific line that polls for input is Input.trigger, you might notice that Z is C, X is B, so what the heck is all that? Well… here’s this for visual help.