Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   Questions and Comments (http://www.alice.org/community/forumdisplay.php?f=9)
-   -   Getting Loopy (http://www.alice.org/community/showthread.php?t=11184)

HoffmanFarmsTx 06-22-2015 08:38 PM

Getting Loopy
 
No lie! I got REAL loopy, in fact the first time I couldn't get out of the loop. I still can't figure out how to make the response not true and have something different happen and end the method with a definitive response like "Goodbye" or "Thanks for playing"

CodeMan 06-23-2015 06:48 AM

[QUOTE=HoffmanFarmsTx;56449]No lie! I got REAL loopy, in fact the first time I couldn't get out of the loop. I still can't figure out how to make the response not true and have something different happen and end the method with a definitive response like "Goodbye" or "Thanks for playing"[/QUOTE]

If you need help just post the world and I take a look at it.

MrMoke 06-23-2015 08:16 AM

Often it simply requires the use of a single test.

Say, for instance, that you have a method with a single "while loop" that continues based on the value of a Boolean value. Then simply add an "If" that does whatever needs to be done until another condition is satisfied, and uses the "else" to set the Boolean variable to false.

While loop terminated :cool:

shoff 06-23-2015 08:25 AM

^^ Good advice.

azgrimm 06-23-2015 07:35 PM

Using the Event System

While [variable] is true

Begin [method]
During [do nothing]
End [method2]

Begin will run your method 1 time when your condition becomes true
End will run a different method 1 time when the condition becomes false.

e.g.

While [objA] is within 5 meters of [objB] is true
Begin [objA] say hello
During: do nothing
End [objA] say Goodbye

in this simple loop when object is within 5 meters of each other the first will say hello, then if you move the objects apart the first will say goodbye.

alternatively if you want to run a method on loop while the condition is met, place it in the During slot


All times are GMT -5. The time now is 08:36 AM.

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