Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Stopping current actions for a simulation (http://www.alice.org/community/showthread.php?t=6705)

jissan11 06-05-2011 01:09 PM

Stopping current actions for a simulation
 
1 Attachment(s)
I have a world where two bumper cars are moving around if you click the green button. What I'm trying to do is to get the red button to stop the movement of the bumper cars (without resetting the world). In other words, to get the bumper cars to stop where they are and to then move again after the green button is pressed. I've tried using a boolean to get to work...but it hasn't. Any help is appreciated.

P.S.: You can do whatever you want to get this to work. i don't have any set requirements.

DeathxKiller 06-05-2011 01:38 PM

we cant do your homewotk for you. this is an alice assignment. try using a lever switch instead of a two button switch. works when i tried it

jissan11 06-05-2011 02:45 PM

I understand that but what i'm asking is help with homework, not doing it. I need to know how to get Alice to stop running the simulation when the button (or switch is that's used instead) is pressed. I could have easily have posed the question with:

How do you stop a set of actions in game?

TauTrumpsPi 06-05-2011 02:59 PM

Use the event "While something is true"

Put the car movements in the during section, and have a boolean variable that changes when you hit the switch in the condition.

Voila

jissan11 06-06-2011 06:01 AM

:confused:
I understand what you are telling me to do except for the following:

-where should the boolean be created? under functions or under properties?
-won't this only allow the code to stop and not restart again once pressed?

Thanks for the help

TauTrumpsPi 06-06-2011 10:03 AM

Use a Boolean variable that changes when you press the button

IF (Variable=true) then
Set value to false
Else
Set value to true

That should change it back and forth and go on and off when you press the button. Make sure your variable is world-level, not class-level.

jissan11 06-06-2011 08:27 PM

1 Attachment(s)
I've tried doing that. It only worked half-way. I could get the sequence of movement to start once I click on the switch, but I can't get it to stop once it has started. I've attached my current stage of my work progress to show what I have done.

Note that when you start the world, the variable "power" reverts to true without having done anything. This might be nothing useful but might be.


All times are GMT -5. The time now is 05:47 AM.

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