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.

Stack Level Too Deep?

Im getting a stack level too deep error on my script. Here is the script below.

Code:
class Scene_Fishing

   def main
    @spriteset = Spriteset_Map.new 
    s1 = "Worm"
    s2 = "Cheese"
    s3 = "Bread"
    s4 = "Salt Pork"
    @command_window = Window_Command2.new(160, [s1, s2, s3, s4])
    @command_window.y = 64
    @command_window.opacity = 160
    if $game_party.item_number(161) == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(0)
    end
    if $game_party.item_number(162) == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(1)
    end
    if $game_party.item_number(163) == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(2)
    end
    if $game_party.item_number(164) == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(3)
    end
    @help_window = Window_Help.new
    @help_window.set_text("Choose your bait.", 1)
    @help_window.opacity = 160
    $bite = false
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @spriteset.dispose
    @command_window.dispose
    @help_window.dispose
    end
  def update
    @spriteset.update
    @command_window.update
    @help_window.update
    update_command
  end
    def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C) 
      if $bite == false
      # Branch by command window cursor position
      case @command_window.index
      when 0  # bait 1
      if $game_party.item_number(161) == 0 
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        @command_window.visible = false
        @command_window.active = false
        $game_party.lose_item(161, 1)
          update_fish
      end
      when 1  # bait 2
      if $game_party.item_number(162) == 0 
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        @command_window.visible = false
        @command_window.active = false
        $game_party.lose_item(162, 1)
        update_fish
      end
      when 2  # bait 3
        if $game_party.item_number(163) == 0 
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        @command_window.visible = false
        @command_window.active = false
        $game_party.lose_item(163, 1)
        update_fish
      end
      when 3  # bait 4
      if $game_party.item_number(164) == 0 
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        @command_window.active = false
        @command_window.visible = false
        $game_party.lose_item(164, 1)
        update_fish
      end
      end
      return
      $bite = true 
    end
  end
end
end

  def update_fish
    @help_window.set_text("Fishing...", 1)
    for i in 0...100
      Graphics.update
     end 
        bite
      if Input.trigger?(Input::B)
        # Play cancel SE
        $game_system.se_play($data_system.cancel_se)
        # Switch to map screen
        $scene = Scene_Map.new
        return
      end
    end

  def bite
    @help_window.set_text("Oh, a bite!", 1)
    if bite == true
     if Input.trigger?(Input::C)
       gain_random_fish
      return
    end
    end
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
  end


def gain_random_fish
     case $game_player.direction
    when 2
      lookingx = $game_player.x
      lookingy = $game_player.y + 1
   when 4
      lookingx = $game_player.x - 1
      lookingy = $game_player.y
    when 6
      lookingx = $game_player.x + 1
      lookingy = $game_player.y
    when 8
      lookingx = $game_player.x
      lookingy = $game_player.y - 1
    end
     case $game_map.terrain_tag(lookingx,lookingy)
    when 6
        $FISH = [153, 154, 155, 156, 157, 158, 159]
    when 7
        $FISH = [142, 143, 144, 145, 146, 147, 148, 149, 150, 151]
      end
  fish2 = rand($FISH.size)
  $game_party.gain_item($FISH[fish2], 1)
  @help_window.set_text("You caught a " + $data_items[$FISH[fish2]].name + "!", 1)
  $game_variables[1] += 1
  $bite = false
  $scene = Scene_Map.new
end
 
The error was,you put an end in line 116 and he gave error in script,I repair two
errors it
1° the line 166
2° in line 9 you put Window_Command2.new,instead of window_Command.new

Your Script repaired:

Code:
class Scene_Fishing

   def main
    @spriteset = Spriteset_Map.new 
    s1 = "Worm"
    s2 = "Cheese"
    s3 = "Bread"
    s4 = "Salt Pork"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4])
    @command_window.y = 64
    @command_window.opacity = 160
    if $game_party.item_number(161) == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(0)
    end
    if $game_party.item_number(162) == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(1)
    end
    if $game_party.item_number(163) == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(2)
    end
    if $game_party.item_number(164) == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(3)
    end
    @help_window = Window_Help.new
    @help_window.set_text("Choose your bait.", 1)
    @help_window.opacity = 160
    $bite = false
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @spriteset.dispose
    @command_window.dispose
    @help_window.dispose
    end
  def update
    @spriteset.update
    @command_window.update
    @help_window.update
    update_command
  end
    def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C) 
      if $bite == false
      # Branch by command window cursor position
      case @command_window.index
      when 0  # bait 1
      if $game_party.item_number(161) == 0 
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        @command_window.visible = false
        @command_window.active = false
        $game_party.lose_item(161, 1)
          update_fish
      end
      when 1  # bait 2
      if $game_party.item_number(162) == 0 
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        @command_window.visible = false
        @command_window.active = false
        $game_party.lose_item(162, 1)
        update_fish
      end
      when 2  # bait 3
        if $game_party.item_number(163) == 0 
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        @command_window.visible = false
        @command_window.active = false
        $game_party.lose_item(163, 1)
        update_fish
      end
      when 3  # bait 4
      if $game_party.item_number(164) == 0 
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        @command_window.active = false
        @command_window.visible = false
        $game_party.lose_item(164, 1)
        update_fish
      end
      end
      return
      $bite = true 
    end
  end
end

def update_fish
  @help_window.set_text("Fishing...", 1)
  for i in 0...100
    Graphics.update
  end 
  bite
  if Input.trigger?(Input::B)
    # Play cancel SE
    $game_system.se_play($data_system.cancel_se)
    # Switch to map screen
    $scene = Scene_Map.new
    return
  end
end

  def bite
    @help_window.set_text("Oh, a bite!", 1)
    if bite == true
      if Input.trigger?(Input::C)
        gain_random_fish
        return
      end
    end
    
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
  end
  
  def gain_random_fish
    case $game_player.direction
    when 2
      lookingx = $game_player.x
      lookingy = $game_player.y + 1
    when 4
      lookingx = $game_player.x - 1
      lookingy = $game_player.y
    when 6
      lookingx = $game_player.x + 1
      lookingy = $game_player.y
    when 8
      lookingx = $game_player.x
      lookingy = $game_player.y - 1
    end
    
  case $game_map.terrain_tag(lookingx,lookingy)
    when 6
      $FISH = [153, 154, 155, 156, 157, 158, 159]
    when 7
     $FISH = [142, 143, 144, 145, 146, 147, 148, 149, 150, 151]
   end
   fish2 = rand($FISH.size)
   $game_party.gain_item($FISH[fish2], 1)
   @help_window.set_text("You caught a " + $data_items[$FISH[fish2]].name + "!", 1)
   $game_variables[1] += 1
   $bite = false
   $scene = Scene_Map.new
 end
end

Bye!
 
in your bite method, replace the code in the if $bite == true with this
Code:
loop do
  Graphics.update
  if Input.trigger?(Input::C)
    break
    gain_random_fish
    return
  end
end

It should work
 
it just stays at the "oh its a bite" window

Code:
class Scene_Fishing

   def main
    @spriteset = Spriteset_Map.new 
    s1 = "Worm"
    s2 = "Cheese"
    s3 = "Bread"
    s4 = "Salt Pork"
    @command_window = Window_Command2.new(160, [s1, s2, s3, s4])
    @command_window.y = 64
    @command_window.opacity = 160
    $bite = false
    if $game_party.item_number(161) == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(0)
    end
    if $game_party.item_number(162) == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(1)
    end
    if $game_party.item_number(163) == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(2)
    end
    if $game_party.item_number(164) == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(3)
    end
    @help_window = Window_Help.new
    @help_window.set_text("Choose your bait.", 1)
    @help_window.opacity = 160
    $bite = false
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @spriteset.dispose
    @command_window.dispose
    @help_window.dispose
    end
  def update
    @spriteset.update
    @command_window.update
    @help_window.update
    update_command
  end
    def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C) 
      if $bite == false
      # Branch by command window cursor position
      case @command_window.index
      when 0  # bait 1
      if $game_party.item_number(161) == 0 
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        @command_window.visible = false
        @command_window.active = false
        $game_party.lose_item(161, 1)
          update_fish
      end
      when 1  # bait 2
      if $game_party.item_number(162) == 0 
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        @command_window.visible = false
        @command_window.active = false
        $game_party.lose_item(162, 1)
        update_fish
      end
      when 2  # bait 3
        if $game_party.item_number(163) == 0 
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        @command_window.visible = false
        @command_window.active = false
        $game_party.lose_item(163, 1)
        update_fish
      end
      when 3  # bait 4
      if $game_party.item_number(164) == 0 
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      else
        @command_window.active = false
        @command_window.visible = false
        $game_party.lose_item(164, 1)
        update_fish
      end
      end
      return
      $bite = true 
    end
  end
end

  def update_fish
    @help_window.set_text("Fishing...", 1)
    for i in 0...100
      Graphics.update
     end 
     $bite = true   
     bite
      if Input.trigger?(Input::B)
        # Play cancel SE
        $game_system.se_play($data_system.cancel_se)
        # Switch to map screen
        $scene = Scene_Map.new
        return
      end
    end

  def bite
    @help_window.set_text("Oh, a bite!", 1)
    loop do
      Graphics.update
      if Input.trigger?(Input::C)
        break
        gain_random_fish
        return
      end
    end
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
  end


def gain_random_fish
     case $game_player.direction
    when 2
      lookingx = $game_player.x
      lookingy = $game_player.y + 1
   when 4
      lookingx = $game_player.x - 1
      lookingy = $game_player.y
    when 6
      lookingx = $game_player.x + 1
      lookingy = $game_player.y
    when 8
      lookingx = $game_player.x
      lookingy = $game_player.y - 1
    end
     case $game_map.terrain_tag(lookingx,lookingy)
    when 6
        $FISH = [153, 154, 155, 156, 157, 158, 159]
    when 7
        $FISH = [142, 143, 144, 145, 146, 147, 148, 149, 150, 151]
      end
  fish2 = rand($FISH.size)
  $game_party.gain_item($FISH[fish2], 1)
  @help_window.set_text("You caught a " + $data_items[$FISH[fish2]].name + "!", 1)
  $game_variables[1] += 1
  $bite = false
  $scene = Scene_Map.new
end
end
 
Post lost from restoring is awesome.

You're missing an Input.update in the bite method's loop.
Also the You caught a ___ would disappear right away without something stop it for a moment.

Code:
  def bite
    @help_window.set_text("Oh, a bite!", 1)
    loop do
      Graphics.update
      Input.update
      if Input.trigger?(Input::C)
        gain_random_fish
        break
      end
    end
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
  end


def gain_random_fish
     case $game_player.direction
    when 2
      lookingx = $game_player.x
      lookingy = $game_player.y + 1
   when 4
      lookingx = $game_player.x - 1
      lookingy = $game_player.y
    when 6
      lookingx = $game_player.x + 1
      lookingy = $game_player.y
    when 8
      lookingx = $game_player.x
      lookingy = $game_player.y - 1
    end
     case $game_map.terrain_tag(lookingx,lookingy)
    when 6
        $FISH = [153, 154, 155, 156, 157, 158, 159]
    when 7
        $FISH = [142, 143, 144, 145, 146, 147, 148, 149, 150, 151]
      end
  fish2 = rand($FISH.size)
  $game_party.gain_item($FISH[fish2], 1)
  @help_window.set_text("You caught a " + $data_items[$FISH[fish2]].name + "!", 1)
  loop do
    Graphics.update
    Input.update
    if Input.trigger?(Input::C)
      break
    end
  end
  $game_variables[1] += 1
  $bite = false
  $scene = Scene_Map.new
end

Replace the last two methods with that.
 

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