Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
break statement??
Old
Delpenator
Guest
 
Status:
Posts: n/a
Default break statement?? - 12-17-2009, 08:16 PM

I know this question has been asked before, and it seems that there is no break statement in alice, which means that is a huge suggestion by me to add to alice 3.0. But, how then, do you stop a loop?

Here is my problem:
I have an event that says if another event is enabled, loop infintely an action. but i want it when a key is typed to use a different method to stop that previous infinite loop. How?

P.S. I don't wanna give an attachment because i want to surprise people with my world.
   
Reply With Quote
There is!
Old
zarfang8
Guest
 
Status:
Posts: n/a
Smile There is! - 12-17-2009, 08:49 PM

Hope is here! The Eventsstopescending property! It has a few problems, but you can break the methods of any object by going into it's seldom used properties and setting the Eventsstopescending property to TRUE! As I said. It does have a few glitches, but give it a try, It might work out.

Or another way to do it is just use a boolean variable inside the loop. All you have to do is put an if/else statement inside an infinite loop, and place a boolean variable inside it. Have when a key is typed, Your boolean variable set value to False. It will stop.

Either way, hope it works out for you, I'm intrested to see what your world is going to be like.

Last edited by zarfang8; 12-17-2009 at 08:52 PM.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 12-17-2009, 08:50 PM

You can make it a while (true) loop and have a boolean variable. So instead of infinite loop you say while (buttonPressed == false) and then do the action to be repeated within the while statement. Then in the method that is initialized with the button, you just put into that method make buttonPressed == false, and it will then stop the while method that is currently running.

This will stop the infinite loop from playing at that time, but I think that it might still be looping in the background, I'm not sure (but its worth a try).


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
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 12-17-2009, 08:53 PM

Quote:
Originally Posted by zarfang8 View Post
Hope is here! The Eventsstopescending property! It has a few problems, but you can break the methods of any object by going into it's seldom used properties and setting the Eventsstopescending property to TRUE! As I said. It does have a few glitches, but give it a try, It might work out.
Hmm, I didn't even know what that did, thanks! That is an important thing that I just learned today that might help me in my later programs. When you use the Eventsstopescending property, do you have to make it false again when you want a method to be run again from that object?

EDIT: I just tried the Eventstopascending thing and it didn't work. I had an infinate loop running and then I had spacebar set the property to true, and the loop kept on going.


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

Last edited by Dameria; 12-17-2009 at 09:00 PM.
   
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 12-17-2009, 10:52 PM

I think it only works for objects selected as parameters for actions, not for event-triggered actions without parameters, as the eventsSopAscending property has to do with how the world treats an object and it's subparts when it is selected as an object parameter.

For example, when you have a game where clicking on a car will make the car turn a different color, it doesn't matter at first whether you click the car's tire or it's body. If the eventsStopAscending property is true, it will matter, as now the subparts are recognized as separate from the main object when clicked.

Note: this is also a good way to make methods which involve clicking on only a part of an object, like clicking ONLY on the tire of the car to make it roll forward.

The reason I know this: that silly Hyper blah blah Go! game I made a while back. I wanted to make it so that if you shot the cork off a bottle, you got points, but I couldn't do that without messing around with the eventsAscending property of the event.


(')>
   
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.