Initialisation

Whenever you start PCC, the following happens:

 What should be in your `autoexec.q'

The `autoexec.q' should define all subroutines and shared variables you use. When PCC saves suspended processes, it only saves currently active subroutines, and only local/static variables. For example, this (silly) script

  Do
    Stop
    MyFancySub
  Loop

will attempt to call `MyFancySub' once it wakes up. So your `autoexec.q' must ensure that `MyFancySub' is available.

Likewise, planet/starship properties should be defined here. When an undeclared property is encountered in a starcharts file, you'll get a warning on the console. If that property has an interesting value (i.e. not EMPTY), it will be automatically declared, to avoid data loss.

Usually, you do not write subroutines directly in `autoexec.q'. It's often better to put related subroutines into a script for themselves, and load that script from the autoexec. For example, if you want to use the `nextturn.q' sample script, add the line

  Load "nextturn.q"

to your autoexec file instead of cut&pasting it.

 `gameinit.q'

I suggest you to place an `autoexec.q' file only in your PCC main directory, and place the statement

  TryLoad "gameinit.q"

somewhere in it. If you want some code executed in all games you play in, place it in the `autoexec.q' file. If you want something to only apply to a particular game (e.g., some helper routines for a particular add-on), put it in the appropriate `gameinit.q' file.


[ << Previous | Up | Next >> ]

Stefan Reuther <Streu@gmx.de>