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 error

What can "too deep" stack error for this line mean:

Code:
      if event.tile_id >= 0 and event != self_event and
         event.x == x and event.y == y and not event.through

I can get it for either lines. It happens when I run a very long and complicated enemy counter event that uses a lot of variables and switches and then initiates a battle screen. But I think the error happens before the battle screen appears and not WHEN it actually appears, as I've done a long wait before the battle screen but after all the switches and stuff and I get the error before the wait.

So my question is, what can the stack error for eitehr of those lines mean? :)
 
That's pretty odd. I have just as long lines, which just as many instances and methods being used (in an if statement).
Are you sure that what you are using of the 'event' instance does not create another stack?

The code alone shouldn't cause this error. There has to be something adding to this, unless I am braindamaged.
The full script, with access to any external methods you are using in the method, would probably be a good idea to toss my way.
 

Zeriab

Sponsor

Twin contacted through messenger and I can say that a pathfinding script caused this. (In possible combination with other scripts, I don't know)

Can you post your pathfinding script so we can have a look at it?
For others here are a more specific error message:

Code:
SystemStackError: stack level too deep

Section025:216:in `passable?'
Section025:214:in `each'
Section025:214:in `passable?'
Section027:150:in `passable?'
Section166:304:in `passable?'
Section166:469:in `add_node'
Section166:449:in `get_adjacent_nodes'
Section166:274:in `calculate_path'
Section166:694:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_type_custom'
Section027:126:in `force_move_route'
Section166:537:in `generate_path'
Section166:695:in `move_typ
 
Looks like my script. Unfortunately I haven't touched that in a long time and can't figure it out. It looks like a problem with generating a new path when character is blocked, so try setting the collision wait value to -1. I'm not sure how you use the script, but you could either change it when calling the setup limit (4th parameter), like this:
Code:
path = A_Star_Pathfinder.new
path.setup(goal, char, limit, -1)
path.calculate_path
path.generate_path

Or change the setup method in AStar_Pathfinder class itself to always set the wait to -1:
Code:
  def setup(goal_node, character, limit, wait = 5, 
            reach = nil, fail = nil, cache = false)
    # The start node is at the character's position
    @start_node = Node.new(character.x, character.y)
    @goal_node = Node.new(goal_node.x, goal_node.y)
    @character = character
    @limit = limit
    @collision_wait = -1       # No. of frames the custom move route
                                      # method should wait before attempting
                                      # to find another path (-1 disables
                                      # these attempts altogether)
    @reach_method = reach             # Proc to call when goal is reached
    @fail_method = fail               # Proc to call when no path is found
    @cache_pass = cache               # If true, map passibility information
                                      # is stored in a table (@pass_map) for
                                      # faster access. 
    @pass_map = nil                   # Table holding passability information
                                      # fill it manually with make_pass_map
                                      # if needed

    @open_list = Array.new            # List of nodes to be checked,
                                      # implemented as a binary heap
    @open_list.push(@start_node)    
    @closed_list = Hash.new           # Set of nodes already checked, this
                                      # is a hash of arrays of [x, y] pairs
                                      # representing map tiles
    @found = false                    # Did we find the optimal path?
  end

Tell me if that fixes it (though if the generate-new-path-when-path-is-blocked feature is essential to your game you might consider another pathfinding script or bug me to look farther into it)
 

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