Nested loops and nested functions problem

For questions about using Classic.

Post » Thu Dec 06, 2007 6:47 pm

Hello there Scirra friends :D 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 :)

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.
[list:s25rdlgo][*:s25rdlgo]How do containers work?[/*:m:s25rdlgo][*:s25rdlgo]Isn't there any Movement SDK? Or the source code for the platform movement plugin?[/*:m:s25rdlgo][/list:u:s25rdlgo]

-Thank you!
By the way,
B
1
G
5
Posts: 8
Reputation: 1,241

Post » Thu Dec 06, 2007 8:42 pm

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 :( I can answer specific questions though...
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Fri Dec 07, 2007 12:15 am

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
B
1
G
5
Posts: 8
Reputation: 1,241

Post » Sat Dec 08, 2007 5:17 pm

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'.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests