Skip to main content

Scripts

Scripts in Pandemic's Script Creator (PSC) are what you primarily create and run, and they consist of Actions that will run in a loop until it's stopped.

How Scripts Work

Scripts run by executing actions from the top to bottom then resets and starts again at the top until the script is stopped.

Actions will only run if its parent action succeeded, giving you the power of performing actions only when you want them to run.

Take a look at this example script to better understand what that means:

Script showing conditional execution

As you can see above:

  1. Our If real skill level is action fails because the character's Agility level isn't high enough
  2. Since that action failed, the inner (or children) actions are skipped
  3. Finally, we execute a simple Log action

After all of that, it will start back at the top of the script and repeat forever (or until the script is stopped).

Best Practices

Embrace the Loop

Many users new to scripting try to make their scripts fully run in a single script loop, and are usually surprised when it doesn't work out too well.

Doing that will often result in rigid, error-prone scripts that can't recover from the slightest disruption.

You want to structure your script so it can loop as often as possible and can be started from any point in your script.

Avoid Long Sleeps

This is related to the previous Best Practice, but is still important to point out separately.

You should use actions like Sleep while animating, Sleep while in combat, and Sleep while moving sparingly, as they take script control from you until they're finished.

A better alternative is to only perform the previous action if you're not animating/sleeping/moving, that way your script is still looping often and you can do other actions as needed (eat food, pray, etc.)

Example of what not to do

Take a look at this script that's doing it the wrong way:

Bad script example

If we attack the Guard successfully, it'll sleep until either we're dead or the Guard's dead, and our script won't run any other actions until that happens.

We can easily improve this by simply reversing the order:

Good script example

With this simple change our script will now have full control the entire time we're fighting.