Pausing a python script

Hello.

I’ve got a python script which is running all the time when the game engine has been started. And i’ve got a boolean property named Done.
My question:
How can I pause the script during Done is false without pausing the whole game engine?

Regards,
unknown_member

Put the whole script in an if condition. eg:

if Done == True:
    ...code...

That way the script won’t run when Done is False.

Yes, but I want the whole code to run and only a pause. Like this:

Run…
Run…
Run…
Run…
Waiting for Done=True…
Waiting…
Waiting…
(Done=True)
Run…
Run…
.
.
.

Use an int to represent states.

if int == 1: # initial, before the bool is true
              run...
              int = 2

if int == 2:
              waiting... # you wouldn't actually do this in the code, this is just for completion.

if int == 3: # the bool is true, this won't run until something external changes int to 3
         run...
             int = 4

if int == 4: # after the bool section has run
             run...
         int = 5

But how can I do the waiting? I tried this:

.
.
.
while (done=false):
     print "Waiting..."
.
.
.

but it paused the whole game engine. Can I probably use a new thread or something like this?

The script runs in ONE frame. It will run when the sensors sent a pulse (TRUE or FALSE) to the controller.

The script should NOT wait!

If you let your script wait (as the loop does) it will block the whole application. Because you delay the one frame where the script runs in.

Like Monster said. You can run your script every frame (or time step whatever you want) with an always sensor and check if done == true. But if you stop the script the whole game will stop and wait for the script.

The reason the whole game paused is because you used a while, which is a loop, but you never made an exit- so you stuck the game in an infinite loop. Use If, not while.