Skip to main content

Variables

Variables are an extremely useful tool which you can use to both store and read values using just a name.

For example, if you wanted to count how many times you've done something, you could use a variable and call it "Count" (or anything you want) and add to it.

Then later if you wanted to print out how many times you did that thing, you could retrieve that value in many different ways using Pandemic's Script Creator (PSC).

One of the easiest ways to use your stored variables would be the Field Command var(Variable Name).

Example Script

Take a look at this example script below, which:

  1. Sets a variable called "Count" to 10
  2. Then loops (runs all the inner actions of the looping action) until our variable "Count" becomes 0
  3. Inside the loop, we are subtracting our "Count" variable by 1, meaning it will call the Subtract action a total of 10 times
  4. Once it has finished looping (meaning "Count" is now 0), we simply log that to the console

Variables in the editor

Last Action's Output

Many actions in PSC will have output, such as If ammo count is or Withdraw all of the first matched item as shown in the Output section.

You can use this output by either using the lastOutput() Field Command or the Set Variable To > Last action's output action to store it in a variable.

tip

With certain actions with an object as output (entities like Players, NPCs, Ground Items, and Game Objects) the last output will actually be that entity. You can use these to do many different things, such as using the "Is variable value" filter to interact with that specific entity at a later time.

Last action's output