PCC implements cooperative multi-tasking. You may not need to worry about this, because I think it's current behaviour is rather intuitive. You can run multiple scripts on different objects. Scripts can suspend for a while, e.g., by using the `WaitOneTurn' subroutine, so other scripts can do their part. Because multi-tasking is cooperative, only scripts that want to suspend actually do it. A script which performs an expensive computation will run to completion (unless the user cancels it using [Ctrl-Break]).
Each command you enter on the console, and each script you run somehow, creates a new process. These processes can suspend themselves (`Stop'), exit (`End') or fail (`Abort', error). Once a process is suspended, PCC saves its execution context in order to resume it later.
WARNING: You can easily overload PCC by creating many processes with a large code base. When PCC suspends a script, and on some other occasions, it must save all its context, and the context includes all statements left on the script. For example, you can easily execute a linear multi-megabyte script file. But if you prefix it with `Stop' or surround it by `Do ... Loop Until False', PCC will fail with an out-of-memory error and kill your script; you will get an error message on the console.
Suspended Scripts |
Scripts which suspend themselves (`Stop') will be remembered by PCC even when you exit and re-load PCC.
You can terminate them, or tell them to run again, using the task manager [Alt-Q]. PCC automatically runs suspended scripts each time you load a game.
If you're visiting a previous turn, PCC will ignore scripts suspended in the current turn, and will not remember scripts you run this session. So your scripts will never see the turn number decrease.
PCC will not remember subroutines and the values of shared variables. If your suspended script calls a subroutine which is not defined in your `autoexec.q' script, it will fail with an error when loaded.
Scripts are saved in a file `vmX.cc', where X is your player number. I'm not yet sure if it's worthwhile and possible to introduce a shared VM file, like for the starcharts file. Note that it's perfectly normal that the VM file changes size and/or contents when you enter PCC and exit it without doing anything.
User-defined object properties (`CreateShipProperty', `CreatePlanetProperty') are saved in the starcharts file (`chartX.cc').