Variable for number of commands in Window_Command?

● ARCHIVED · READ-ONLY
Started by Rello 7 posts View original ↗
  1. Preface: Sorry if this is the wrong section. My coding vernacular is limited (still learning), so excuse any inaccurate terms I may use (though correcting me would be appreciated).

    Hey all,

    Hopefully this is a relatively easy question to answer. I'm using Switches to control the amount (and which) commands appear in Window_MenuCommand. I am also using those switches to determine the height of the Windows itself. Rather than having a handful of If statements, is there a variable that basically stores the amount of commands currently displayed? There's a large chance I overlooked it. Something like:

    #-------------------------------------------------------------------------- # * Get Window Height #-------------------------------------------------------------------------- def window_height return fitting_height(command_size) endwould be preferred to my current:

    #-------------------------------------------------------------------------- # * Get Window Height #-------------------------------------------------------------------------- def window_height if $game_switches[15] or if $game_switches[16] return 224 elsif $game_switches[15] and $game_switches[16] return 248 else return 200 end endAny help is appreciated, thanks!
  2. Why bothering with switch ?  Does $game_variables can't be used @@a ?
  3. Because not all commands will be available at the get-go; using the switches allows me to add commands to the window when I need them.

    I supposed I could use an in-game variable to track this, but I wasn't sure if there was a way to pull the number of commands within the code itself. 
  4. Actually I'm a bit confused here.. uhh maybe I'm a dumb. But why $game_variables can't do what $game_switches can do? I think $game_variables is more powerful than $game_switches.

    You can set the window height with the value of $game_variables, then..

    You can do just like this:
    if $game_variables[iD] == 224

     # add one command

    elsif $game_variables[iD] == 248

     # add two command

    etc

    end

    end

    Oh then, why you don't use item_max method? By default that method will look and return how many the command in a window.

    Okay basically you need to provide more information about how you add command, and etc. Because adding command to a window dynamically is well a bit different as I recall, I mean you know by default command is declared at the initialization of a window, I'm not saying that what you want is impossible because I have done it several times, but again as I recall it need more work around.


     
  5. Because using variables in this way isn't as concrete. If I were to just increase a variable's value that controls all commands, I'd had to be far more careful making sure no values overlap. It's just easier for me to add commands by activating their respective switches.

    But yes, Item_Max seems to be working the way I want it to (after some minor tweaking). Thank for bringing that up!
  6. Why the value will be overlap? The one who set the value is you right? Still confused I am @@2. I just think that by utilize variable you just need to use 1 variable to do all what , while using switches you need more than 1 right? But that's okay if you already solve that matter, congratz :)
    By the way is there anything else?
  7. This should be done for you. Window_Command from line 25 is as follows:

      #--------------------------------------------------------------------------  # * Get Window Height  #--------------------------------------------------------------------------  def window_height    fitting_height(visible_line_number)  end  #--------------------------------------------------------------------------  # * Get Number of Lines to Show  #--------------------------------------------------------------------------  def visible_line_number    item_max  end  #--------------------------------------------------------------------------  # * Get Number of Items  #--------------------------------------------------------------------------  def item_max    @list.size  endAs long as you're giving it the commands in the right way, it should be the right size for the amount of commands you give.