Condition menu in a script

Hello, I use the script from Yanfly called Ace Equip Engine : https://yanflychannel.wordpress.com/rmvxa/gameplay-scripts/ace-equip-engine/


I need to know if it's possible to make a condition in a script to know if the player is in the equipment selection menu.
not exactly - what you do is place a command in each menu that stores it in a variable if the player enters that menu, and have the exit function for all menus clear that variable.


After that, any of your scripts can check where the player currently is by checking that variable.
Okay, I understand the idea. But I'm not very competent in script. How to write it ?
That isn't easily explained to someone who doesn't know programming, so let's take a step back.


Why do you want to check that? What difference does that make to the game mechanics?


I originally assumed it was because you wanted to script something, but if you don't know much about scripting then it's probably something else - and in most non-script-cases, there are better ways to handle such situations. But I can only help after I know what you want to do (as opposed to knowing how you want to do it)
Ok, I explained my problem.


In my game, I included special equipments with sets. When a set's equipment is worn by a character, we can see an interface by pressing a button from the Equipment menu (in my capture below, the menu which I speak) :





If the selected equipment is not a set's equipement, nothing happens. But if there a set's equipement and I want to change my stuff, when I'm on the equipment selection screen (as below) and I push the button, I can't see the interface (that's good) but I hear the cursor noise.





The script that handles the display of the interface is defined as follows :

Code:
if EME::SHOW_IN_EQUIP_MENU
	  class Scene_Equip
	   
	   
	   
	    alias start_set_equipement start
	    def start
	      start_set_equipement
	      create_sets_window
	      $menu_set_color = "EQUIP"
	    end
	   
	    def create_sets_window
	      @sets_window = Window_Sets_Show.new
	      @sets_window.openness = 0
	      @sets_window.z = 200
	      @sets_showing = false
	    end
	   
	    alias update_patch_set_equipement update
	    def update
	      update_patch_set_equipement
	      item = @actor.equips[@slot_window.index]
	      return unless item
	      if Math.get_charact("<Set_Equip = ",">",item.note)
	        if Input.trigger?(EME::TOUCHE_WINDOW_E)
	          if @sets_showing
	            Sound.play_cancel
	          else
	            Sound.play_cursor
	          end
	          switch_sets
	        end
	      end
	      update_show_sets if @sets_showing
	    end
	   
	    def switch_sets
	      if @sets_showing
	        hide_sets
	      else
	        show_sets
	      end
	    end
	   
	    def update_show_sets
	      return unless @sets_showing
	      if @sets_window.active
	        if Input.repeat?(:UP)
	          Sound.play_cursor
	          @sets_window.prev_ligne
	        elsif Input.repeat?(:DOWN)
	          Sound.play_cursor
	          @sets_window.next_ligne
	        elsif Input.trigger?(:B)
	          Sound.play_cancel
	          switch_sets
	        end
	      end
	    end
	   
	    def show_sets
	      return unless @slot_window.active
	      item = @actor.equips[@slot_window.index]
	      return unless item
	      if Math.get_charact("<Set_Equip = ",">",item.note)
	        return if Math.get_charact("<Set_Equip = ",">",item.note) == nil
	        @sets_window.x = @slot_window.x #[[@item_window.x,@item_window.x+rect.x+12-rect.width/2].max,@item_window.x+@item_window.width-@sets_window.width].min
	        @sets_window.y = @slot_window.y #[[@item_window.y,@item_window.y+rect.y+12-rect.height/2].max,@item_window.y+@item_window.height-@sets_window.height].min
	        @sets_window.height = @slot_window.height
	        @sets_window.width = Graphics.width
	        @sets_window.item = item
	        @sets_window.reset_ligne
	        @sets_window.actor = @actor
	        @sets_window.open unless @sets_window.open?
	        @sets_showing = true
	        @slot_window.active = false
	        @slot_window.close unless @slot_window.close?
	        @status_window.close unless @status_window.close?
	      end
	    end
	    def hide_sets
	      @sets_window.close unless @sets_window.close?
	      @slot_window.active = true
	      @slot_window.open unless @slot_window.open?
	      @status_window.open unless @status_window.open?
	      @sets_showing = false
	    end
	   
	  end
	end




That's why I search a method to verify that the player is on the equipment selection screen to avoid the cursor noise.
It IS possible to check in what scene the player currently is, it is a built-in method, a very handy one in that.


if SceneManager.scene_is?(Scene_Equip)


This would check if the scene is the equip scene or not.


You can check for all scenes in the game, just replace 'Scene_Equip' with the name of the scene class you want to check for.


But you used quite a confusing explanation, because if I understood it right, you want to check if a specific window is active or not.


Screen or menu means the whole menu which appears on the screen. That is the scene itself.


To check if a window is active or not, you would use this:


if @window_name.active


Replace '@window_name' with the name of the window you want to check for.


You should be able to find which window name you need if you look through the Scene_Equip class. 


The slot selection window is '@slot_window', I think, and the equipment selection window is '@item_window', if I remember right, but still check it, I haven't checked that class for a while now. 
Thanks for your explanations. With @slot_window, I succeeded to solve my problem. Thanks you very much.

Original thread: https://forums.rpgmakerweb.com/threads/condition-menu-in-a-script.57227/