Condition menu in a script

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,434
Reaction score
7,713
First Language
German
Primarily Uses
RMMV
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.
 

Nérylis

Veteran
Veteran
Joined
Feb 14, 2015
Messages
193
Reaction score
3
First Language
French
Primarily Uses
Okay, I understand the idea. But I'm not very competent in script. How to write it ?
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,434
Reaction score
7,713
First Language
German
Primarily Uses
RMMV
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)
 

Nérylis

Veteran
Veteran
Joined
Feb 14, 2015
Messages
193
Reaction score
3
First Language
French
Primarily Uses
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.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
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. 
 

Nérylis

Veteran
Veteran
Joined
Feb 14, 2015
Messages
193
Reaction score
3
First Language
French
Primarily Uses
Thanks for your explanations. With @slot_window, I succeeded to solve my problem. Thanks you very much.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

On my journey of character rework: I had this character, she was meant to be just a princess that joins your party. And at long term she was just uninteresting... So I tweaked her to be a rebel agaisn't the royalty before meeting up with the party.

Quick tip for any other ametuer pixel artists! When trying to create a colour palette, enabling Antialiasing can speed up the process of creating different shades! Just place your lightest colour and your darkest colour next to each other, select both pixels, and stretch it out!
Revolutionizing the JRPG Industry: Knocking on Doors.

Take that, murderhobos.
Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.

Forum statistics

Threads
106,054
Messages
1,018,580
Members
137,843
Latest member
Betwixt000
Top