"Stack level too deep" error

When I'm trying to start "playtest", there is an error named: SystemStackError occurred: stack level too deep.

I think this is because I use two scripts that are almost the same.

I can't delete one of them...

The script I'm using is for an extra option in the title screen, are there any other options to solve this problem?

#============================================================================

# Zerbu Engine - Extra Starting Position Option

#----------------------------------------------------------------------------

# This script adds an extra "New Game" type option to the menu that allows you

# to specify a different starting location. This is good for creating

# playable tutorials.

#============================================================================

 

#============================================================================

# (module) ZE_Extra_Starting_Position_Option

#============================================================================

module ZE_Extra_Starting_Position_Option

  ZE_ESPO = {

#------------------------------------------------------------------------

# Options

#------------------------------------------------------------------------

# This is the text that will appear on the title screen.

#------------------------------------------------------------------------

:NAME => "Extra",

#------------------------------------------------------------------------

# This is the number for the map the player should start on when the

# extra option is selected.

#------------------------------------------------------------------------

:MAP => 28,

#------------------------------------------------------------------------

# This is the X and Y position the player should start at when the

# extra option is selected.

#------------------------------------------------------------------------

:MAP_X => 11,

:MAP_Y => 3,

  }

end

 

#============================================================================

# Window_TitleCommand

#============================================================================

class Window_TitleCommand

  include ZE_Extra_Starting_Position_Option

  #--------------------------------------------------------------------------

  # alias method: make_command_list

  #--------------------------------------------------------------------------

  alias ze_espo_make_command_list make_command_list

  def make_command_list

#---

ze_espo_make_command_list

add_command(ZE_ESPO[:NAME], :espo)

#---

  end

end

 

#============================================================================

# Scene_Title

#============================================================================

class Scene_Title

  include ZE_Extra_Starting_Position_Option

  #--------------------------------------------------------------------------

  # alias method: create_command_window

  #--------------------------------------------------------------------------

  alias ze_espo_create_command_window create_command_window

  def create_command_window

#---

ze_espo_create_command_window

@command_window.set_handler🙂espo, method🙂command_espo))

#---

  end

 

  #--------------------------------------------------------------------------

  # new method: command_espo

  #--------------------------------------------------------------------------

  def command_espo

#---

DataManager.create_game_objects

#---

$game_party.setup_starting_members

#---

$game_map.setup(ZE_ESPO[:MAP])

#---

$game_player.moveto(ZE_ESPO[:MAP_X], ZE_ESPO[:MAP_Y])

$game_player.refresh

#---

Graphics.frame_count = 0

#---

close_command_window

fadeout_all

#---

$game_map.autoplay

#---

SceneManager.goto(Scene_Map)

#---

  end

  end
The only things I've changed in the other script are purple.
Stack Level Too Deep error occurs when you call too many layers of codes, usually it's because a piece of code is calling itself recursively. The most common source of this problem is when a script is listed twice. Firstly, please check if you had any duplicates of a same script. Then, if there is no duplicates, please post/give a link to the other script, as I can't see any recursive problem in this script.
I'm indeed using two scripts that are almost the same but I can't delete one of them as I've said.

But this script here could be a problem too...

#==============================================================================

# ** Scene_Title

#------------------------------------------------------------------------------

#  This class performs the title screen processing.

#==============================================================================

 

class Scene_Title < Scene_Base

  #--------------------------------------------------------------------------

  # * Start Processing

  #--------------------------------------------------------------------------

  def start

    super

    SceneManager.clear

    Graphics.freeze

    create_background

    create_foreground

    create_command_window

    play_title_music

  end

  #--------------------------------------------------------------------------

  # * Get Transition Speed

  #--------------------------------------------------------------------------

  def transition_speed

    return 20

  end

  #--------------------------------------------------------------------------

  # * Termination Processing

  #--------------------------------------------------------------------------

  def terminate

    super

    SceneManager.snapshot_for_background

    dispose_background

    dispose_foreground

  end

  #--------------------------------------------------------------------------

  # * Create Background

  #--------------------------------------------------------------------------

  def create_background

    @sprite1 = Sprite.new

    @sprite1.bitmap = Cache.title1($data_system.title1_name)

    @sprite2 = Sprite.new

    @sprite2.bitmap = Cache.title2($data_system.title2_name)

    center_sprite(@sprite1)

    center_sprite(@sprite2)

  end

  #--------------------------------------------------------------------------

  # * Create Foreground

  #--------------------------------------------------------------------------

  def create_foreground

    @foreground_sprite = Sprite.new

    @foreground_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)

    @foreground_sprite.z = 100

    draw_game_title if $data_system.opt_draw_title

  end

  #--------------------------------------------------------------------------

  # * Draw Game Title

  #--------------------------------------------------------------------------

  def draw_game_title

    @foreground_sprite.bitmap.font.size = 48

    rect = Rect.new(0, 0, Graphics.width, Graphics.height / 2)

    @foreground_sprite.bitmap.draw_text(rect, $data_system.game_title, 1)

  end

  #--------------------------------------------------------------------------

  # * Free Background

  #--------------------------------------------------------------------------

  def dispose_background

    @sprite1.bitmap.dispose

    @sprite1.dispose

    @sprite2.bitmap.dispose

    @sprite2.dispose

  end

  #--------------------------------------------------------------------------

  # * Free Foreground

  #--------------------------------------------------------------------------

  def dispose_foreground

    @foreground_sprite.bitmap.dispose

    @foreground_sprite.dispose

  end

  #--------------------------------------------------------------------------

  # * Move Sprite to Screen Center

  #--------------------------------------------------------------------------

  def center_sprite(sprite)

    sprite.ox = sprite.bitmap.width / 2

    sprite.oy = sprite.bitmap.height / 2

    sprite.x = Graphics.width / 2

    sprite.y = Graphics.height / 2

  end

  #--------------------------------------------------------------------------

  # * Create Command Window

  #--------------------------------------------------------------------------

  def create_command_window

    @command_window = Window_TitleCommand.new

    @command_window.set_handler🙂new_game, method🙂command_new_game))

    @command_window.set_handler🙂continue, method🙂command_continue))

    @command_window.set_handler🙂shutdown, method🙂command_shutdown))

    @command_window.set_handler🙂extra, method🙂command_extra))

    @command_window.set_handler🙂help, method🙂command_help))

    end

  #--------------------------------------------------------------------------

  # * Close Command Window

  #--------------------------------------------------------------------------

  def close_command_window

    @command_window.close

    update until @command_window.close?

  end

  #--------------------------------------------------------------------------

  # * [New Game] Command

  #--------------------------------------------------------------------------

  def command_new_game

    DataManager.setup_new_game

    close_command_window

    fadeout_all

    $game_map.autoplay

    SceneManager.goto(Scene_Map)

  end

  #--------------------------------------------------------------------------

  # * [Continue] Command

  #--------------------------------------------------------------------------

  def command_continue

    close_command_window

    SceneManager.call(Scene_Load)

  end

  #--------------------------------------------------------------------------

  # * [shut Down] Command

  #--------------------------------------------------------------------------

  def command_shutdown

    close_command_window

    fadeout_all

    SceneManager.exit

  end

  #--------------------------------------------------------------------------

  # * Play Title Screen Music

  #--------------------------------------------------------------------------

  def play_title_music

    $data_system.title_bgm.play

    RPG::BGS.stop

    RPG::ME.stop

  end

  #=============================

  # Extra command

  #=============================

  def command_extra

    DataManager.setup_new_game

    close_command_window

    fadeout_all

    $game_map.autoplay

    SceneManager.goto(Scene_Map)

  end

  #=============================

  # help command

  #=============================

  def command_help

    DataManager.setup_new_game

    close_command_window

    fadeout_all

    $game_map.autoplay

    SceneManager.goto(Scene_Map)

  end

end
the problem is most probably in create_command_window, the second script overwrites that function while the first one aliases it.


Which order do you have for those scripts?


They might work together if the Zerbu script is the second one, below the other scene_title-script you're pasted in your post #3


If that already is the case, then someone needs to combine both functions (and thereby both scripts) to prevent the error.


Also, please always provide links to the original place of those scripts, don't simply paste them here - the original internet site for that script often contains additional info, manuals or bugfixes that might help in problem solving.
This is the link to zerbu's engine: http://www.rpgmakervxace.net/topic/724-zerbu-engine-extra-starting-position-option-from-title-screen/

I don't really get your question about which order i have.

But if you mean where they're pasted:

The script with the commands are in the section "Scene_title".

I pasted zerbu's engine in the section "Materials"
with "order" I meant the sequence from top down in which they were posted under "materials", because you should never place a script above "Materials".

The other script, the one you placed into "scene_title", was that a complete script replacement or did you just insert a few lines?

If you edited just a few lines, which were those?

Regularly, that should also have been placed below materials - even if that would have needed additional data to allow it to override the default scripts.

If it had been written that way instead of replacing a default script, then your problem would have been much easier to solve.

Please link where you got that modified scene_title from, perhaps there is info to salvage the situation short of rewriting those scripts...
The script scene_title is original from the system itself, I've only added some things to make it work with the other script.

The things I've added in the script are purple marked.

#==============================================================================

# ** Scene_Title

#------------------------------------------------------------------------------

#  This class performs the title screen processing.

#==============================================================================

 

class Scene_Title < Scene_Base

  #--------------------------------------------------------------------------

  # * Start Processing

  #--------------------------------------------------------------------------

  def start

    super

    SceneManager.clear

    Graphics.freeze

    create_background

    create_foreground

    create_command_window

    play_title_music

  end

  #--------------------------------------------------------------------------

  # * Get Transition Speed

  #--------------------------------------------------------------------------

  def transition_speed

    return 20

  end

  #--------------------------------------------------------------------------

  # * Termination Processing

  #--------------------------------------------------------------------------

  def terminate

    super

    SceneManager.snapshot_for_background

    dispose_background

    dispose_foreground

  end

  #--------------------------------------------------------------------------

  # * Create Background

  #--------------------------------------------------------------------------

  def create_background

    @sprite1 = Sprite.new

    @sprite1.bitmap = Cache.title1($data_system.title1_name)

    @sprite2 = Sprite.new

    @sprite2.bitmap = Cache.title2($data_system.title2_name)

    center_sprite(@sprite1)

    center_sprite(@sprite2)

  end

  #--------------------------------------------------------------------------

  # * Create Foreground

  #--------------------------------------------------------------------------

  def create_foreground

    @foreground_sprite = Sprite.new

    @foreground_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)

    @foreground_sprite.z = 100

    draw_game_title if $data_system.opt_draw_title

  end

  #--------------------------------------------------------------------------

  # * Draw Game Title

  #--------------------------------------------------------------------------

  def draw_game_title

    @foreground_sprite.bitmap.font.size = 48

    rect = Rect.new(0, 0, Graphics.width, Graphics.height / 2)

    @foreground_sprite.bitmap.draw_text(rect, $data_system.game_title, 1)

  end

  #--------------------------------------------------------------------------

  # * Free Background

  #--------------------------------------------------------------------------

  def dispose_background

    @sprite1.bitmap.dispose

    @sprite1.dispose

    @sprite2.bitmap.dispose

    @sprite2.dispose

  end

  #--------------------------------------------------------------------------

  # * Free Foreground

  #--------------------------------------------------------------------------

  def dispose_foreground

    @foreground_sprite.bitmap.dispose

    @foreground_sprite.dispose

  end

  #--------------------------------------------------------------------------

  # * Move Sprite to Screen Center

  #--------------------------------------------------------------------------

  def center_sprite(sprite)

    sprite.ox = sprite.bitmap.width / 2

    sprite.oy = sprite.bitmap.height / 2

    sprite.x = Graphics.width / 2

    sprite.y = Graphics.height / 2

  end

  #--------------------------------------------------------------------------

  # * Create Command Window

  #--------------------------------------------------------------------------

  def create_command_window

    @command_window = Window_TitleCommand.new

    @command_window.set_handler🙂new_game, method🙂command_new_game))

    @command_window.set_handler🙂continue, method🙂command_continue))

    @command_window.set_handler🙂shutdown, method🙂command_shutdown))

    @command_window.set_handler🙂extra, method🙂command_extra))

    @command_window.set_handler🙂help, method🙂command_help))

    end

  #--------------------------------------------------------------------------

  # * Close Command Window

  #--------------------------------------------------------------------------

  def close_command_window

    @command_window.close

    update until @command_window.close?

  end

  #--------------------------------------------------------------------------

  # * [New Game] Command

  #--------------------------------------------------------------------------

  def command_new_game

    DataManager.setup_new_game

    close_command_window

    fadeout_all

    $game_map.autoplay

    SceneManager.goto(Scene_Map)

  end

  #--------------------------------------------------------------------------

  # * [Continue] Command

  #--------------------------------------------------------------------------

  def command_continue

    close_command_window

    SceneManager.call(Scene_Load)

  end

  #--------------------------------------------------------------------------

  # * [shut Down] Command

  #--------------------------------------------------------------------------

  def command_shutdown

    close_command_window

    fadeout_all

    SceneManager.exit

  end

  #--------------------------------------------------------------------------

  # * Play Title Screen Music

  #--------------------------------------------------------------------------

  def play_title_music

    $data_system.title_bgm.play

    RPG::BGS.stop

    RPG::ME.stop

  end

  #=============================

  # Extra command

  #=============================

  def command_extra

    DataManager.setup_new_game

    close_command_window

    fadeout_all

    $game_map.autoplay

    SceneManager.goto(Scene_Map)

  end

  #=============================

  # help command

  #=============================

  def command_help

    DataManager.setup_new_game

    close_command_window

    fadeout_all

    $game_map.autoplay

    SceneManager.goto(Scene_Map)

  end

end
I've simply copied the "def New_game" command (blue) and pasted it in the script.

Then I've changed the name of the command otherwise it wouldn't work with the window_command given above.
Copying both your modification to Scene_Title and Tutorial script to a new project, I spot no error, though why you modify Scene_Title that way, I don't have a clue, you did not push command items to Window_TitleMenu after all, but that's not here or there. The point is that The Stack Level error did not happen for me. Maybe you accidentally copied some scripts twice to your project.
I got the problem, you can't use zerbu's extra option engine two times...

I've deleted one option and when I started the game it just worked properly.

I think I need some kind of special script to combine the two scripts in one script that doesn't overwrite eachother.

I finally managed to combine the two scripts in one script by adding some commands.  🙂

This tread can now be closed.
Which is exactly what the first person to reply said - that you're using the same script twice.


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/stack-level-too-deep-error.24442/