PDA

View Full Version : infinite loop while doing other stuff?


louieansonng
02-12-2010, 03:21 AM
Hey, is there a way of making an infinite loop while it does other actions? I used the endless loop on a cone to make it a tornado, but I want it to suck things at the same time, and when it sucks a human, the tornado stops...

x2495iiii
02-12-2010, 07:13 AM
Sure. Have them happen in separate methods that are called from the same do together method.

Niteshifter
02-12-2010, 12:52 PM
I would personally recommend to not use infinite loops as you can't start and stop it in case you want to check for bugs. The way I go about doing this is using boolean variables and the while event ;).

louieansonng
02-13-2010, 10:22 AM
Thanks for the replies. It took me a while to figure out how the variables in Alice work...turns out the parameters are below the methods...that's why i couldn't drag the variables I made in the properties window..lol

Dameria
02-13-2010, 10:36 AM
I would recommend using recursive methods, where there is an if/else statement saying if a boolean variable "tornadoOn" == true, then it spins a little bit and then calls upon the same method. And then you can have a method in it where if something happens (where you want the tornado to stop), then you do tornadoOn == false. So it keeps spinning until tornadoOn == false, and then stops the loop.

With an infinite loop there is almost no way to stop the method.

zonedabone
02-13-2010, 10:39 AM
Calling a recursive method over and over again can crash alice, not just the world, but ALICE!!!!!!!:eek:

I think it takes around a couple thousand times, but it does!!!!

Dameria
02-13-2010, 10:46 AM
I know, but that is why you have to control the recursive method with a simple if/else statement. If you can control how many times you want the method to loop, then it can be safe.