Alice Community  

Go Back   Alice Community > General Discussion > Questions and Comments

Reply
 
Thread Tools Display Modes
infinite loop while doing other stuff?
Old
louieansonng
Guest
 
Status:
Posts: n/a
Default infinite loop while doing other stuff? - 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...
Attached Files
File Type: a2w Trial.a2w (5.83 MB, 11 views)
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 02-12-2010, 07:13 AM

Sure. Have them happen in separate methods that are called from the same do together method.


(')>
   
Reply With Quote
Old
Niteshifter
Guest
 
Status:
Posts: n/a
Default 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 .
   
Reply With Quote
Old
louieansonng
Guest
 
Status:
Posts: n/a
Default 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
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 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.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 577
Join Date: Nov 2008
Location: In the interwebs
Default 02-13-2010, 10:39 AM

Calling a recursive method over and over again can crash alice, not just the world, but ALICE!!!!!!!

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


'Apple Macintosh' - An anagram of 'Complaints Heap'

M.A.C.I.N.T.O.S.H. - Machine Always Crashes, If Not, The Operating System Hangs.

You're *such* a mac person.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 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.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.