Nested loops and nested functions problem

This forum is currently in read-only mode.
From the Asset Store
40 ambient sound loops. A wide selection of looping ambient sounds for different locations.
  • Hello there Scirra friends <img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /> I've been toying out with Construct since I've found it out (two days ago) and I'm facing a little problem.

    Right now, I'm porting to Construct the core of my Sonic Worlds engine (made in MMF2) and I'm facing some troubles setting up some of the basic routines.

    I manage collision detection by a serie of method summons to reposition sensors acordingly to the ground alignment, having each of them an specific method name, and a master one that I use for summoning them all at once.

    At first, I've tryied to implement this by the use of functions, but stragently enough, when nested functions were called, the runtime wouldn't even get to create the game window, just quit without any sort of warning. However, I tryied to workaround this and go for the MMF way and use loops.

    I've noticed, you've implemented a loop name recognition system for preventing recursive loops. However, due some sort of glitch, loop names aren't correctly recogniced, as the fact the error thrown by the runtime:

    I have two differently named loops (called "Player_Sensors" and "Player_Sensors_Main", for example). Once I try to summon the Player_Sensors_Main loop from the Player_Sensors loop, it throws a recursive loop call error.

    I would've tryied to look at the source code, but I don't know where the code that manages the loop statement is, or neither how the general engine works, so I'd be grateful if you could find out the problem <img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" />

    I'm pretty sure that if I get this done soon, it could help to grow Construct's fanbase for other people.

    Also, I have two other questions, but not necessary to reply about them now.

    • How do containers work?
    • Isn't there any Movement SDK? Or the source code for the platform movement plugin?

    -Thank you!

    By the way,

  • What events are you using to get the recursive loop error?

    Containers make objects get picked by events at the same time, so they kind of pair up. For example you could put a tank turret and its base in a container so any events relating to a base automatically relate to its associated turret as well, instead of all turrets. You have to have equal numbers of each object in the container though. Containers deserves an article for full explanation, which is on my ever-growing todo list!

    As for the movement SDK, use the Plugin SDK and specify the OF_MOVEMENTPLUGIN flag in IDE_FLAGS in Main.h. A few of the routines which dont apply aren't called, and the member pLink is the pointer to the associated instance to move. Apart from that most things are the same (ACEs, runtime functions etc). It also deserves its own SDK, example movement as open source and documentation etc, but I don't have time right now <img src="{SMILIES_PATH}/icon_sad.gif" alt=":(" title="Sad" /> I can answer specific questions though...

  • Hmmm, actually, I've messed with the loops problem some more, and it's quite weird: When I summon the "Player_Sensor" loop, all the other loops wich start with the same name are executed aswell...

    That may be the reason the runtime threw the recursive loop error.

    Edit: Let me upload the file with the problem somewhere.

    Edit 2: While trying to reproduce the problem on a separated code file, there were no problems with the loops. Weird :e. I'll upload the original file.

    Here it is

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hmm... this .cap runs for me, not sure what it's meant to do though. Where do you come across a recursive loop error? Also, out of curiosity, why do you run a loop once? (The function object effectively does this, and is much better at it)

    Another thing to try is replacing your events with 'Start loop' actions with conditions like 'For'.

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