There are a few ways to have PCC2 execute your scripts automatically.

  • Immediately after starting, PCC2 looks for a script pcc2init.q.
    • Windows: in your profile folder, subdirectory PCC2 (for example, C:\Documents and Settings\YourName\Application Data\PCC2 or C:\Users\YourName\AppData\PCC2)
    • Unix: your home directory, subdirectory .pcc2 (for example, /home/yourname/.pcc2)
    Note that this directory changed in beta 13; previous versions look for that file directly in the profile/home directory.
  • PCC2 also loads plugins.
  • After setting up game directory names, PCC2 looks for a script autoexec.q in your game directory (very similar to how PCC 1.x looks for autoexec.q). This file is run in the EnterDirectory hook.

These scripts can contain your code. In particular, it makes sense to put the following things into your startup scripts:

  • Subroutine definitions (Sub statement).
  • Property definitions (CreateShipProperty and CreatePlanetProperty statements).
  • Key bindings (Bind statement) that make your subroutines accessible from the graphical interface.
  • Hook definitions (On statement) that execute your subroutines at various events (currently of interest is the Load event, which you can use to perform some tasks whenever PCC2 loads your game).

If you have written a useful script, it may make sense to wrap it as a plugin.

In addition, you can load script files from the console by typing a command such as Load "/path/to/script.q", and you can execute subroutines by simply calling them from the console.

One big difference between PCC 1.x and PCC2 is that PCC2 has a game chooser that allows you to load multiple games in one session. This means that it is possible that PCC2 loads your autoexec.q file multiple times in one session, whereas PCC 1.x will only load it once.