Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Adding More than just a new command.....

I've seen topics like this before, but the ones I've seen don't have quite what I need. I've been playing around in Scene_Title trying to get a new command in the title menu. I have had partial success. I need it so that when you select the command New Game, it bring's up two more options, Easy and Hard. I am using the ADB system and I want it so that the user can select which type of system to use, Passive or Active.

The codes are as following:

Code:
$game_system.ffxii_config.active = false
for easy

and

Code:
$game_system.ffxii_config.active = true
for hard.

Help in this would be very greatly appreciated!
 
This seems to do the trick!  ^^

Code:
class Scene_Title
  alias old_main main
  alias old_update update
  alias old_command_new_game command_new_game
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    old_main
    # Dispose of difficulty window
    if @difficulty_window
      @difficulty_window.dispose unless @difficulty_window.disposed?
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    unless @command_window.active
      # Update difficulty selection window
      @difficulty_window.update
      # If C button was pressed
      if Input.trigger?(Input::C)
        # Set difficulty (false = easy, true = hard)
        $game_system.ffxii_config.active = @difficulty_window.index == 1
        old_command_new_game
      end
      # If B button was pressed
      if Input.trigger?(Input::B)
        # Play cancel SE
        $game_system.se_play($data_system.cancel_se)
        # Go back to command window
        @difficulty_window.dispose
        @command_window.visible = true
        @command_window.active = true
      end
      return
    end
    old_update
  end
  #--------------------------------------------------------------------------
  # * Command: New Game
  #--------------------------------------------------------------------------
  def command_new_game
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Hide command window
    @command_window.visible = false
    @command_window.active = false
    # Make difficulty selection window
    s1 = "Easy"
    s2 = "Hard"
    @difficulty_window = Window_Command.new(128, [s1, s2])
    @difficulty_window.back_opacity = 160
    @difficulty_window.x = 352 - @command_window.width / 2
    @difficulty_window.y = 288
  end
end

Paste below Scene_Debug but above Main.
 
ok. It works! It give me the choice to select easy or hard, but I doesn't set it to easy or hard. I went in and made one minor edit.

In Frame Update:
Code:
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    unless @command_window.active
      # Update difficulty selection window
      @difficulty_window.update
      # If C button was pressed
      if Input.trigger?(Input::C)
        # Set difficulty (false = easy, true = hard)
        $game_system.ffxii_config.active = @difficulty_window.index == 1
        old_command_new_game
      end
      # If B button was pressed
      if Input.trigger?(Input::B)
        # Play cancel SE
        $game_system.se_play($data_system.cancel_se)
        # Go back to command window
        @difficulty_window.dispose
        @command_window.visible = true
        @command_window.active = true
      end
     # Set difficulty upon select
      case @difficulty_window.index
      when 0  # Easy
        $game_system.ffxii_config.active = false
      when 1  # Hard
        $game_system.ffxii_config.active = true
      end
      return
    end
    old_update
  end

I added in the [# Set difficulty upon select] part of the code so it would set the difficulty. Thanks for the help!
 
Really?  This is the line that should have set the switch:
Code:
$game_system.ffxii_config.active = @difficulty_window.index == 1

Perhaps I was too ambitious with my fancy compressed code.  Perhaps you need parentheses around (@difficulty_window.index == 1)

I'd recommend at least moving the difficulty select code you wrote to the spot in the code where that line was.  Otherwise it's resetting ffxii_config.active every frame, even before you confirm a difficulty level.  It won't break anything to leave it the way it is, but it's less efficient programming.  ;D
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top