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.

I'm stumped.

I've been working on this for awhile, and one portion has me stumped.

In Hero Rental (a game I'm scripting for, link found in my signature - Userbar) I was making a bunch of Extras. One of them was a script that would allow for a unique experiance. (no not THAT experiance)

You can change the text background.

However, whenever I tried it, it didn't work.

First off, I created the portion in the title menu.
This isn't a problem, so i believe.
s1 = "Begin a Journey"
s2 = "Continue Your Quest"
s3 = "Extras"
s4 = "End Game"
@command_window = Window_Command.new(215, [s1, s2, s3, s4])
@command_window.back_opacity = 0
@command_window.x = 150 - @command_window.width / 2
@command_window.y = 200
I have a lot of coding in it, but that is the main portion, i have all the loading and stuff, it works.

However, the problem comes in this part of the extras section, it bumps me to a whole new game, without changing it. I know I am probably using the wrong coding, if i am, can you tell me what i should use?

#--------------------------------------------------------------------------
# * Command: Extras
#==========================================================================
def command_extras(nosound = false)
x5 = "Blue"
x6 = "Red"
@command_window = Window_Command.new(150, [x5, x6])
x5 = @windowskin_name = $Blue01
x6 = @windowskin_name = $Red01
return
end
# Update game screen
Graphics.update
# Update input information
Input.update
end

Any ideas?
 
im not exactly sure what you are doing but:

Code:
x5 = @windowskin_name = $Blue01
x6 = @windowskin_name = $Red01

is contradictory ;) You are changing the @windowskin_name twice in a row.

Code:
def command_extras(nosound = false)
x5 = "Blue"
x6 = "Red"
@command_window = Window_Command.new(150, [x5, x6])
x5 = @windowskin_name = $Blue01
x6 = @windowskin_name = $Red01
return
end
# Update game screen
Graphics.update
# Update input information
Input.update
end

and doesn't that give you a synthax error?
 
No, when it creates the window, each of the new choices (Blue01 and Red01) are automatically seperated, so it isn't contradictory.

You may be right though, and if you are, do you think you could help me out by creating a script that will be able to change the windowskin? Thanks mo.
 
hmm..well its contradictory because, you are reassigning the variable 2 different values in a row which cancels out the first assignment but changing @windowskin_name won't make a difference if I remember right. you need too look at Window_Base.

look:
Code:
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # Reset if windowskin was changed
    if $game_system.windowskin_name != @windowskin_name
      @windowskin_name = $game_system.windowskin_name
      self.windowskin = RPG::Cache.windowskin(@windowskin_name)
    end
  end

What you need to do is this:
$game_system.windowskin_name = (new window skin name)
 
Then I have another problem. How do I make it so you can choose which one? I get unitialized constant for Blue01 and Red01 (my two cmd thingys)
Here is my whole Scene_Title

#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs title screen processing.
#==============================================================================

class Scene_Title
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# If battle test
if $BTEST
battle_test
return
end
# Load database
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
# Make system object
$game_system = Game_System.new
# Make title graphic
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
# Make command window
s1 = "Begin a Journey"
s2 = "Continue Your Quest"
s3 = "Extras"
s4 = "End Game"
@command_window = Window_Command.new(215, [s1, s2, s3, s4])
@command_window.back_opacity = 0
@command_window.x = 150 - @command_window.width / 2
@command_window.y = 200
# Continue enabled determinant
# Check if at least one save file exists
# If enabled, make @continue_enabled true; if disabled, make it false
@continue_enabled = false
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
@continue_enabled = true
end
end
# If continue is enabled, move cursor to "Continue"
# If disabled, display "Continue" text in gray
if @continue_enabled
@command_window.index = 1
else
@command_window.disable_item(1)
end
# Play title BGM
$game_system.bgm_play($data_system.title_bgm)
# Stop playing ME and BGS
Audio.me_stop
Audio.bgs_stop
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of command window
@command_window.dispose
# Dispose of title graphic
@sprite.bitmap.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update command window
@command_window.update
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # New game
command_new_game
when 1 # Continue
command_continue
when 2 # Extras
command_extras
when 3 # Shutdown
command_shutdown
end
end
end
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game(nosound = false)
# Play decision SE
$game_system.se_play($data_system.decision_se) unless nosound
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up initial party
$game_party.setup_starting_members
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Command: Continue
#--------------------------------------------------------------------------
def command_continue(nosound = false)
# If continue is disabled
unless @continue_enabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se) unless nosound
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se) unless nosound
# Switch to load screen
$scene = Scene_Load.new
end
#--------------------------------------------------------------------------
# * Command: Shutdown
#--------------------------------------------------------------------------
def command_shutdown
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Fade out BGM, BGS, and ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# Shutdown
$scene = nil
end
#--------------------------------------------------------------------------
# * Command: Extras
#==========================================================================
def command_extras(nosound = false)
x5 = "Blue"
x6 = "Red"
@command_window = Window_Command.new(150, [x5, x6])
x6 = $game_system.windowskin_name != (Blue01)
x5 = $game_system.windowskin_name != (Red01)
return
end
# Update game screen
Graphics.update
# Update input information
Input.update
end

#==========================================================================
# * Frame Update for Above Cmd
#==========================================================================
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# Reset if windowskin was changed
if $game_system.windowskin_name != @windowskin_name
@windowskin_name = $game_system.windowskin_name
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
end
end
#==========================================================================
# * Battle Test
#--------------------------------------------------------------------------
def battle_test
# Load database (for battle test)
$data_actors = load_data("Data/BT_Actors.rxdata")
$data_classes = load_data("Data/BT_Classes.rxdata")
$data_skills = load_data("Data/BT_Skills.rxdata")
$data_items = load_data("Data/BT_Items.rxdata")
$data_weapons = load_data("Data/BT_Weapons.rxdata")
$data_armors = load_data("Data/BT_Armors.rxdata")
$data_enemies = load_data("Data/BT_Enemies.rxdata")
$data_troops = load_data("Data/BT_Troops.rxdata")
$data_states = load_data("Data/BT_States.rxdata")
$data_animations = load_data("Data/BT_Animations.rxdata")
$data_tilesets = load_data("Data/BT_Tilesets.rxdata")
$data_common_events = load_data("Data/BT_CommonEvents.rxdata")
$data_system = load_data("Data/BT_System.rxdata")
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up party for battle test
$game_party.setup_battle_test_members
# Set troop ID, can escape flag, and battleback
$game_temp.battle_troop_id = $data_system.test_troop_id
$game_temp.battle_can_escape = true
$game_map.battleback_name = $data_system.battleback_name
# Play battle start SE
$game_system.se_play($data_system.battle_start_se)
# Play battle BGM
$game_system.bgm_play($game_system.battle_bgm)
# Switch to battle screen
$scene = Scene_Battle.new
end
 
Let me rephrase it.
I am trying to make it so you can change the window skin color, and my script isn't working. Anyone got one?


Also: Does anyone know how to transfer a player to a specific map?
 
I can't help you wit the window_skin color as it would take too long but here is how you transfer a player:

Code:
    # Set transferring player flag
    $game_temp.player_transferring = true
    # Set player move destination
    $game_temp.player_new_map_id = MAPID
    $game_temp.player_new_x = NEWX
    $game_temp.player_new_y = NEWY
    $game_temp.player_new_direction = NEWDIRECTION
 

khmp

Sponsor

Well you want to make a menu to change the windowskin. And this is the code you are using?

def command_extras(nosound = false)
x5 = "Blue"
x6 = "Red"
@command_window = Window_Command.new(150, [x5, x6])
x5 = @windowskin_name = $Blue01
x6 = @windowskin_name = $Red01
return
end
# Update game screen
Graphics.update
# Update input information
Input.update
end

Ok so to start you are creating two temporary variables and storing the strings "Blue" and "Red". Then you create a command window to present these two strings as options. Then you are overwriting these variables and storing two globals in them. You are also changing the window skin twice and after the update of this window is called the @windowskin_name will be whatever was contained in $Red01. But there's an end block further on. This wil create an error. Before this you have a Graphics.update and Input.update.

The reason it crashes because of an uninitialized variable is because $Red01 was never declared before this code was encountered. Right after the command window is created in main add these two lines:
Code:
$Red01 = 'red_windowskin.png'
$Blue01 = 'blue_windowskin.png'

Of course replace those strings with the actual names of the window skins you have in your window skin directory.

Code:
#============================================================================
# ** Scene_Title
#----------------------------------------------------------------------------
# This class performs title screen processing.
#============================================================================


class Scene_Title
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # If battle test
    if $BTEST
      battle_test
      return
    end
    # Load database
    $data_actors = load_data("Data/Actors.rxdata")
    $data_classes = load_data("Data/Classes.rxdata")
    $data_skills = load_data("Data/Skills.rxdata")
    $data_items = load_data("Data/Items.rxdata")
    $data_weapons = load_data("Data/Weapons.rxdata")
    $data_armors = load_data("Data/Armors.rxdata")
    $data_enemies = load_data("Data/Enemies.rxdata")
    $data_troops = load_data("Data/Troops.rxdata")
    $data_states = load_data("Data/States.rxdata")
    $data_animations = load_data("Data/Animations.rxdata")
    $data_tilesets = load_data("Data/Tilesets.rxdata")
    $data_common_events = load_data("Data/CommonEvents.rxdata")
    $data_system = load_data("Data/System.rxdata")
    # Make system object
    $game_system = Game_System.new
    # Make title graphic
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title($data_system.title_name)
    # Make command window
    s1 = "Begin a Journey"
    s2 = "Continue Your Quest"
    s3 = "Extras"
    s4 = "End Game"
    @command_window = Window_Command.new(215, [s1, s2, s3, s4])
    @command_window.back_opacity = 0
    @command_window.x = 150 - @command_window.width / 2
    @command_window.y = 200
    
    @Red01 = 'red_windowskin.png'
    @Blue01 = 'blue_windowskin.png'
    @Default = $game_system.windowskin_name

    # Continue enabled determinant
    # Check if at least one save file exists
    # If enabled, make @continue_enabled true; if disabled, make it false
    @continue_enabled = false
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.rxdata")
        @continue_enabled = true
      end
    end
    # If continue is enabled, move cursor to "Continue"
    # If disabled, display "Continue" text in gray
    if @continue_enabled
      @command_window.index = 1
    else
      @command_window.disable_item(1)
    end
    # Play title BGM
    $game_system.bgm_play($data_system.title_bgm)
    # Stop playing ME and BGS
    Audio.me_stop
    Audio.bgs_stop
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of command window
    @command_window.dispose
    # Dispose of title graphic
    @sprite.bitmap.dispose
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update command window
    @command_window.update
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
        when 0 # New game
          command_new_game
        when 1 # Continue
          command_continue
        when 2 # Extras
          command_extras
        when 3 # Shutdown
          command_shutdown
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Command: New Game
  #--------------------------------------------------------------------------
  def command_new_game(nosound = false)
    # Play decision SE
    $game_system.se_play($data_system.decision_se) unless nosound
    # Stop BGM
    Audio.bgm_stop
    # Reset frame count for measuring play time
    Graphics.frame_count = 0
    # Make each type of game object
    $game_temp = Game_Temp.new
    $game_system = Game_System.new
    $game_switches = Game_Switches.new
    $game_variables = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen = Game_Screen.new
    $game_actors = Game_Actors.new
    $game_party = Game_Party.new
    $game_troop = Game_Troop.new
    $game_map = Game_Map.new
    $game_player = Game_Player.new
    # Set up initial party
    $game_party.setup_starting_members
    # Set up initial map position
    $game_map.setup($data_system.start_map_id)
    # Move player to initial position
    $game_player.moveto($data_system.start_x, $data_system.start_y)
    # Refresh player
    $game_player.refresh
    # Run automatic change for BGM and BGS set with map
    $game_map.autoplay
    # Update map (run parallel process event)
    $game_map.update
    # Switch to map screen
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # * Command: Continue
  #--------------------------------------------------------------------------
  def command_continue(nosound = false)
    # If continue is disabled
    unless @continue_enabled
    # Play buzzer SE
    $game_system.se_play($data_system.buzzer_se) unless nosound
    return
    end
    # Play decision SE
    $game_system.se_play($data_system.decision_se) unless nosound
    # Switch to load screen
    $scene = Scene_Load.new
  end
  #--------------------------------------------------------------------------
  # * Command: Shutdown
  #--------------------------------------------------------------------------
  def command_shutdown
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Fade out BGM, BGS, and ME
    Audio.bgm_fade(800)
    Audio.bgs_fade(800)
    Audio.me_fade(800)
    # Shutdown
    $scene = nil
  end
  #--------------------------------------------------------------------------
  # * Command: Extras
  #==========================================================================
  def command_extras
    # Create a new command window
    new_command_window = Window_Command.new(150, ['Blue', 'Red', 'Default'])
    # Loop continually until the user is done.
    loop do
      new_command_window.update
      Graphics.update
      Input.update
      case new_command_window.index
        when 0 # 'Blue'
          $game_system.windowskin_name = @Blue01
        when 1 # 'Red'
          $game_system.windowskin_name = @Red01
        when 2 # 'Default'
          $game_system.windowskin_name = @Default
      end
      # If the user is done selecting a windowskin
      break if Input.trigger?(Input::B)
    end
    # Dispose of the window
    new_command_window.dispose
  end

  #==========================================================================
  # * Battle Test
  #--------------------------------------------------------------------------
  def battle_test
    # Load database (for battle test)
    $data_actors = load_data("Data/BT_Actors.rxdata")
    $data_classes = load_data("Data/BT_Classes.rxdata")
    $data_skills = load_data("Data/BT_Skills.rxdata")
    $data_items = load_data("Data/BT_Items.rxdata")
    $data_weapons = load_data("Data/BT_Weapons.rxdata")
    $data_armors = load_data("Data/BT_Armors.rxdata")
    $data_enemies = load_data("Data/BT_Enemies.rxdata")
    $data_troops = load_data("Data/BT_Troops.rxdata")
    $data_states = load_data("Data/BT_States.rxdata")
    $data_animations = load_data("Data/BT_Animations.rxdata")
    $data_tilesets = load_data("Data/BT_Tilesets.rxdata")
    $data_common_events = load_data("Data/BT_CommonEvents.rxdata")
    $data_system = load_data("Data/BT_System.rxdata")
    # Reset frame count for measuring play time
    Graphics.frame_count = 0
    # Make each game object
    $game_temp = Game_Temp.new
    $game_system = Game_System.new
    $game_switches = Game_Switches.new
    $game_variables = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen = Game_Screen.new
    $game_actors = Game_Actors.new
    $game_party = Game_Party.new
    $game_troop = Game_Troop.new
    $game_map = Game_Map.new
    $game_player = Game_Player.new
    # Set up party for battle test
    $game_party.setup_battle_test_members
    # Set troop ID, can escape flag, and battleback
    $game_temp.battle_troop_id = $data_system.test_troop_id
    $game_temp.battle_can_escape = true
    $game_map.battleback_name = $data_system.battleback_name
    # Play battle start SE
    $game_system.se_play($data_system.battle_start_se)
    # Play battle BGM
    $game_system.bgm_play($game_system.battle_bgm)
    # Switch to battle screen
    $scene = Scene_Battle.new
  end
end

Alright that's basically what it boils down too. The problem I encountered in testing was that the windowskin_name although changed in the current window was not permanent. Can't figure it out exactly. It replaces the windowskin_name global so it should carry across but it doesn't it's very odd. Hmmm Perhaps someone else can answer why? Or figure out where the script that already does this is hidden.

In any case good luck with it! :thumb:
 
I'll look around. I think I know the problem though, you need an input trigger to apply it, ironically.

Heres another problem for ya : How do i make it so i can choose if the player wants to go to that option or another one (this time using a input trigger, so that it doesn't automatically carry them?)
 

khmp

Sponsor

How do i make it so i can choose if the player wants to go to that option or another one (this time using a input trigger, so that it doesn't automatically carry them?)

You mean you want the window skin to change when they select it instead? Not just change it when the selection cursor is over it? I'm assuming that's what you meant sorry if I'm wrong.

Wrap up the case statement inside command_extras with this:
Code:
if Input.trigger?(Input::C)
  # case statement here
end
 
K, It doesn't work really, but i'm getting there. Anyway, last question: If i do a new_command_window.dispose then I can't get back to the screen before it (i.e. the window with choices of what you want to do) any ideas? also how do i break so it will go to the title menu again?

break if Input.trigger?(Input::B) doesn't work.
 
Code:
 def command_extras
    # Create a new command window
    print("Currently only 2 options are available. This is a beta test.")
    new_command_window = Window_Command.new(150, ['Music', 'Window Skin'])
     loop do
       new_command_window.update
       Graphics.update
       Input.update
    if Input.trigger?(Input::C)
      case new_command_window.index
      when 0 #Music
    # Set transferring player flag
    # Set player move destination
      $Game_Temp = Game_Temp.new
    $game_temp.player_transferring = true
    $game_temp.player_new_map_id = 4
    $game_temp.player_new_x = 9
    $game_temp.player_new_y = 13
    $game_temp.player_new_direction = 8
    
    when 1 #Window Skin
    new_command_window.dispose
    new_command_window = Window_Command.new(150, ['Blue', 'Red', 'Default', 'Go Back'])
    # Loop continually until the user is done.
    loop do
      new_command_window.update
      Graphics.update
      Input.update
      if Input.trigger?(Input::C)
      break if Input.trigger?(Input::B)
      case new_command_window.index
          when 0 # 'Blue'
            $game_system.windowskin_name = @Blue01
          when 1 # 'Red'
            $game_system.windowskin_name = @Red01
          when 2 # 'Default'
            $game_system.windowskin_name = @Default
  def update
    # Reset if windowskin was changed
    if $game_system.windowskin_name != @windowskin_name
      @windowskin_name = $game_system.windowskin_name
      self.windowskin = RPG::Cache.windowskin(@windowskin_name)
    end
  end
            break
          when 3 #Go Back
            break
      # If the user is done selecting a windowskin
      break if Input.trigger?(Input::B)
    end
  end
end
    # Dispose of the window
    new_command_window.dispose
  end

can you try to edit it so that breaking works and goes back to the screen before it. Also can you try to make the transfer work?
 

khmp

Sponsor

Ok, quick glance you have a loop within a loop. This is why those 'end's should be placed on the same indentation as the beginning of said code block. Right now its highly unreadable. I can't tell right off the bat where the loops end or where the function ends. But the first loop doesn't end before the second one starts. This is mucho bad. Its the reason that when you break through the inner loop it gets caught in the outer loop which sends it back into the inner loop.

However I can solve one thing. Variables are always case sensitive. The reason $game_temp didn't work is because you capitalized it. So if you make it lower case there won't be an error there.

I'll look at it and try to put it into working order.

Code:
  #--------------------------------------------------------------------------
  # * Command: Extras
  #--------------------------------------------------------------------------
  def command_extras
    print("Currently only 2 options are available. This is a beta test.")

    # Create a new command window
    new_command_window = Window_Command.new(150, ['Music', 'Window Skin'])

    # This boolean is enabled only if the user wants to look at the selection of
    # window skins.
    window_skins = false

    # Loop continually until the user is done.
    loop do
      new_command_window.update
      Graphics.update
      Input.update
      break if Input.trigger?(Input::B)
      if Input.trigger?(Input::C)
        case new_command_window.index
          when 0 #Music
            # Just get the player into the game.
            command_new_game
            break
          when 1 #Window Skin
            # Enable the boolean to show that the user wants a new windowskin.
            window_skins = true
            break
        end
      end
    end
    # Toss the window we are done with it.
    new_command_window.dispose
    
    # If the user selected the second choice start the window skin selection
    # method.
    if window_skins
      command_windowskins
    end
  end
  #--------------------------------------------------------------------------
  # * Command: WindowSkin Selection
  #--------------------------------------------------------------------------  
  def command_windowskins
    # Create the new window with the new selection.
    new_command_window = Window_Command.new(150, ['Blue', 'Red', 'Default', 'Go Back'])

    # Make a boolean to later be enabled if the user wants to go back.
    go_back = false

    # Loop continually until the user is done.
    loop do
      new_command_window.update
      Graphics.update
      Input.update
      break if Input.trigger?(Input::B)
      if Input.trigger?(Input::C)
        case new_command_window.index
          when 0 # 'Blue'
            $game_system.windowskin_name = @Blue01
          when 1 # 'Red'
            $game_system.windowskin_name = @Red01
          when 2 # 'Default'
            $game_system.windowskin_name = @Default
          when 3 # Go Back
            go_back = true
            break
        end
      end
    end
    # Toss the window.
    new_command_window.dispose
    
    # If the user wanted to go back to the previous window.
    if go_back
      command_extras
    end
  end

Done I created a new function to separate the loops so it looks a tad nicer. Made it nice and readable with comments. I changed the player transfer protocol to that of just calling command_newgame. Hope you don't mind it seems like from what the code said that's what you were trying to do.

Good luck with it shiroun! :thumb:
 
Lol, it works except for changing the window skin, which may be my fault b/c I forgot to add in the variable for it. Minor detail though, I need to transfer him to a certain map, not to the start of the game.

Gonna search it
 

khmp

Sponsor

Got it solved. First the reason the window skin wasn't being saved. When a new game is started the global game_system is reinitialized and if it contained anything it would be forgot. Which is what we were doing. Saving the window skin inside the global and then when a new game is started its forgotten. So I made an alias method of command_new_game to save the old windowskin if any and now the change is more permanent. Next the player transferring thing is done as well. I cheated though and just call command_new_game and then call the code Mr.Mo wrote.

So here's the alias method that you can just throw at the bottom of the class definition. Before the last end.
Code:
  alias_method :old_command_new_game, :command_new_game
  def command_new_game(nosound = false)
    windowskin_name = $game_system.windowskin_name
    old_command_new_game(nosound)
    $game_system.windowskin_name = windowskin_name
  end

Next replace your 'command_extra's code with this:
Code:
  #--------------------------------------------------------------------------
  # * Command: Extras
  #--------------------------------------------------------------------------
  def command_extras
    print("Currently only 2 options are available. This is a beta test.")

    # Create a new command window
    new_command_window = Window_Command.new(150, ['Music', 'Window Skin'])

    # This boolean is enabled only if the user wants to look at the selection of
    # window skins.
    window_skins = false

    # Loop continually until the user is done.
    loop do
      new_command_window.update
      Graphics.update
      Input.update
      break if Input.trigger?(Input::B)
      if Input.trigger?(Input::C)
        case new_command_window.index
          when 0 #Music
            # Just get the player into the game.
            command_new_game
            $game_temp.player_transferring = true
            $game_temp.player_new_map_id = 4
            $game_temp.player_new_x = 9
            $game_temp.player_new_y = 13
            $game_temp.player_new_direction = 8
            break
          when 1 #Window Skin
            # Enable the boolean to show that the user wants a new windowskin.
            window_skins = true
            break
        end
      end
    end
    # Toss the window we are done with it.
    new_command_window.dispose
    
    # If the user selected the second choice start the window skin selection
    # method.
    if window_skins
      command_windowskins
    end
  end

If you have any problems with it just tell me.

Good luck with it shiroun! :thumb:
 
Uhh, only one problem which is that when you try to exit the 1st menu, it gives you an error with the alias,
alias_method :eek:ld_command_new_game, :command_new_game
def command_new_game(nosound = false)
windowskin_name = $game_system.windowskin_name
old_command_new_game(nosound)
$game_system.windowskin_name = windowskin_name
end

oh yea, and the windowskin doesn't work with that lol.
 

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