View Single Post
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 01-21-2009, 12:09 PM

Quote:
Originally Posted by Jaker48895 View Post
... something ... called "World.heli_running" ... in a lot of you commands. I wonder what this is, and how can i make one?
That's a world level boolean variable and is pretty much the key to the whole thing. It is true when the motor is running and false when it's not. You can always test it in other programs and have them respond appropriately (i.e., take off or not).

Since it is a world level, it does not reset to the default value until the world stops (unlike a variable local to a method which resets to the default when the method completes).

To create it, go to the world properties box and click on "create new variable." Also a hint for debugging: It's very useful to play your program on a relatively small screen positioned so you can also see the variable in this box. The box will always show the variables current value as the program is running - and if you've made an error in your logic, it will be painfully obvious.

As a final note, this approach is also the reason I made the comment that the example really wasn't "good code." Hopefully Alice 3.0 will handle variable scope in a more OOP manner. I'll leave explaining what that means to others, however - just know this way isn't it - but it is the only way I know to handle this sort of thing in Alice 2.0.
Attached Images
File Type: jpg World-Level Variable.JPG (10.5 KB, 53 views)
   
Reply With Quote