0 Favourites

Need help with looped functions

  • Hello, I'm just trying to make some pathfinding system, and I've got a problem!

    This is my function called "findpath". It does some actions and checkes if current array slot is finish point ( = "F" ). If its not ("ELSE"), then function must call itself and do this actions again and again, until it will get to the finish (there is always 100% way to reach finish point).

    But Im keep getting this error:

    Here is the line:

    Please, help!

  • Each time it is called in the "findpath" function, the for each XY element loops through the whole Path array. During that loop-through, every time the Else is triggered (which could be a lot, depending on how many "F" values it contains) it then calls the "findpath" function to run the for each XY element loop all over again... Which means it will run the for each XY loop as an infinitely self-triggering loop. I think... from looking at the event sheet.

  • Each time it is called in the "findpath" function, the for each XY element loops through the whole Path array. During that loop-through, every time the Else is triggered (which could be a lot, depending on how many "F" values it contains) it then calls the "findpath" function to run the for each XY element loop all over again... Which means it will run the for each XY loop as an infinitely self-triggering loop. I think... from looking at the event sheet.

    It contains 1 F value. There is no problem with XY loop, Im only getting error because of this else if I'm checking values in array's loop.

    For example, I have my base code (which is working pretty well), and there is no problem.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • How do you know that line of code equates to the else condition? If you disable the else does the error still happen? I note that the other function calls also send parameters whereas the call after the else does not - perhaps that could be the source of the undefined error. Hard to say any more from the images.

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