Incredibly bizarre bug involving the text "right"...

0 favourites
  • 3 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • First, let me say that this is probably the strangest thing I have ever encountered in Construct 2, so I really hope someone can shed some light on the problem.

    So I was attempting to create a simple maze generator in Construct 2 with the tilemap similar to Prim's Algorithm. To keep track of the current position of the end of the maze, I had an object called "marker" that would move around according to the following. At the beginning of each frame, it would call a function called "get" to generate a direction to move in. It was supposed to work by (every time "get" was called) randomly setting a text variable called "direction" to either "up", "left", "down" or "right". If the random generator spat out (For example.) "up" it would check to see if the tile above the "marker" was occupied; if it was, it would call "get" again. It would continue doing this until it got a suitable direction. At the time of posting this, the "marker" was not yet programmed to actually move, simply to check where it could move. I had it set so that "get" would be called at the start of the layout or upon on a mouse click.

    I should also mention that unless I otherwise specify, I am always undoing my changes before testing a new solution.

    The problem started simply: at the start of the layout, it would always set "direction" to "right" even if the tile to the right of the "marker" was occupied. Upon clicking the mouse (And calling "get" again.) it would randomly pick between all suitable directions as it should... Plus right. (Even if the tile to the right of the "marker" was still occupied.) I first tried rearranging the order of the events with no change in this behavior. I then tried deleting all the code that had anything to do with the direction "right". Upon running I would immediately get an error: Uncaught RangeError: Maximum call stack size exceeded. If I undid my deletion of the code it would run as before. If I deleted the code involved with another direction (For example "up") it would still run as before minus the deleted direction. I tried searching my project for "right" and saw only the events previously mentioned. I tried disabling the all of the code involved with choosing any direction and it ran just fine. (But without choosing a direction.) After undoing my changes I tried only disabling the code involved with picking a new direction if the tile to the right of the marker was already occupied. It always still picked right uppon running the layout. I then tried only deleting "right" from the "choose" expression that was randomly picking the directions. This time I again got the "Uncaught RangeError". Deleting any other directions from the "choose" expression gave me no "Uncaught RangeError"s. Lastly and most weirdly, I delete the code responsible picking a new direction if the tile to the right of the marker is already occupied; while leaving "right" in the "choose" expression. If I run it still always first picks "right" but it gives me no "Uncaught RangeError". But if I then re-write the code I deleted (Without undoing) it gives me the error.

    Needless to say, this is incredibly bizarre and I can think of no reason whatsoever that would cause this to happen. This might be a problem with my computer or some 3rd party plugin I have installed (Though there or none used in this file) so I've included a download link. If others encounter the same problem or have any ideas then please respond with your thoughts.

    This file has not been altered since writing this post.

    Construct 2 beta release r254

    https://drive.google.com/uc?export=down ... CWo6ZbHWPG

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It's a simple mistake - in your event #18 you have right_o="right"

    should be direction="right"

    There is a better way to do this, without recursive function call:

    Loopindex<50 condition is used to prevent infinite loops.

  • dop2000 Yup, that solved it. I figured it would be something simple like that.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)