Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   How do i stop a method? (http://www.alice.org/community/showthread.php?t=3627)

rohan123444 12-14-2009 07:04 PM

How do i stop a method?
 
How do I stop a method which uses an infinite loop. Basically what im doing is if the switch is up this method runs which uses an infinite loop to move two cars but what i need help on is stopping the method when the switch is turned to the off position. The problem is since the method uses an infinite loop the method never ends, therefore i cant stop it.

HELP WOULD BE APPRECIATED.

rockstar442 12-14-2009 07:11 PM

ok dude im confused with what you want post up your thing and ill help you out

rohan123444 12-14-2009 07:16 PM

Here is my program
 
1 Attachment(s)
I have a method that has an infinite loop. I want it it so when i flip a switch the method stops, but it doesn't seem to be working since there is in an infinite loop. You will see in my program.

rockstar442 12-14-2009 07:20 PM

ok give me a moment

rohan123444 12-14-2009 07:44 PM

Any luck with it?
 
Any luck with solving the problem so far?

rockstar442 12-14-2009 07:47 PM

sorry man no i havnt gotten it so far i dont get exactly what you did but im working on it till then keep trying

Dameria 12-14-2009 08:16 PM

I'll check into it, give me a moment to try it.

rockstar442 12-14-2009 08:26 PM

dude do you get confused too????

Dameria 12-14-2009 08:29 PM

1 Attachment(s)
Well I had to rush this because I have to go, but this is what I came up with so far, hope it helped. I made it while switch is not up (by the way you have the switch upside down) then it starts it, and when the switch is switched off, it stops the actions. It does not stop the actions mid move however, it has to wait until the method runs through, then it stops. So it stops the infinite loop, but only when the method finishes.

Tell me if this is what you were looking for please.

x2495iiii 12-14-2009 09:18 PM

If it isn't, you could add checks into the movement method to make it stop more quickly when the switch is flipped to off. I could show you how to do that.

rohan123444 12-15-2009 05:59 PM

Could you show me?
 
Could you ^ show me how to do it by posting it on here, and if i have any other problems ill post them here.

Dameria 12-15-2009 06:02 PM

Did you download mine and see if that is what you wanted?

rohan123444 12-15-2009 06:02 PM

Dameria
 
In the program you posted Dameria how did you get the world event where you got while the world is running? and another thing what did you do that made it work, like the reasoning behind it.

rohan123444 12-15-2009 06:09 PM

Dameria
 
Yes i did download yours and thank you very much, that is what i wanted, but now i want to know what is the reasoning behind it that it worked by what you did and how did you get while the world is running as a world event in the world events section?

rohan123444 12-15-2009 06:17 PM

[QUOTE=Dameria;14658]Did you download mine and see if that is what you wanted?[/QUOTE]

Yes it is what i wanted and thank you. But now i have another problem, i changed up the program so that if each each car gets too close to the wall it turns individually and doesn't cause the other car to turn as well. Now the problem is if car1 gets too close car2 stops moving while car1 fixes its problem, i kind of fixed it but it doesnt look correct, if there is any more i can do to fix it can you fix the program then post it again

rohan123444 12-15-2009 06:19 PM

1 Attachment(s)
and here is the program

Dameria 12-15-2009 06:28 PM

Sorry I don't have time right now to view your program, but I got the While loop from the bottom, same place where the if/else statement and loops are, it just says While. Also, I made it so after every time the method finishes and it is about to go again, it checks to make sure the lever is not up (again, the level was upside down, so it is when the lever IS up), then it would do the method again, but if the lever was down it would do nothing. It is basically like having an infinite loop with an if/else statement in it. It infinitely checks too see if the variable for lever is up or not. If lever is not up, then it will run the method, if not it will do nothing and keep checking until the lever is turned up.

zarfang8 12-15-2009 08:09 PM

Maybe you could use Eventsstopescending. Its a seldom used variable in just about every item except for the world, light, and the camera.

awest 12-18-2009 09:07 PM

Dameria, How did you.....
 
Dameria,

In your help.a2w world you created an event called "While the world is running". How did you create the "While the world is running". The only While statement I get is "While something is True" with seemingly no ability to change it to "While the world is running".

thanks

x2495iiii 12-18-2009 09:11 PM

Right click a when the world start event to get the option to change it to while the world is running.

awest 12-21-2009 12:35 AM

thank you
 
Thank you, x2495iiii. That did the trick.

lynnebittner 06-03-2010 06:37 AM

how to stop a ball rolling
 
How do I stop a ball rolling after a loop?


All times are GMT -5. The time now is 03:19 PM.

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