The PCC Script Library


Here you find scripts for PCC. Each script contains some more or less useful function. Generally, you should load the script into PCC with the Load command from your autoexec.q file. Then, some new commands will be available on the console.

If you have written a useful script, you can submit it to me (Streu@gmx.de) and I will place it here. If you modify and improve a script, I'd like to hear from you, too.

You can also download all scripts at once: ccscripts.zip (41k).

Note: some scripts may only run on a recent PCC version; not all contain an appropriate notice.

Note 2: Scripts can do almost anything to your game which is permitted by the rules. Especially for "global action"-style scripts, you should have an idea how it works before letting it go on live game data.

auto.q Auto Tasks
autoexec.q Stefan's Autoexec Script
bum.q Cloaked Ship Detection using `bum'/`btm'
cargo.q Cargo Transfer `Macros'
checker.q Simple Turn Checker
comment.q Comment Timestamps
explmap.q Explore map tracker
fborg.q Show Hyperjump Routes ending at a Planet (including 3 Ly square GravityWell)
fixtow.q PCC Sample Script -- Fix Towees
goto.q Go to object - quickly
hidename.q Hide Ship Names
load.q Load Minerals for Fighter / Torpedo Building
marker.q Display Markers at Current Position
move.q Advanced "MoveTo" command
nextturn.q PCC Sample Script -- What will I have here next turn?
plist.q PList support for PCC
psmap.q Experimental PostScript Map Printer
revive.q Revive PCC
savehost.q Save Game as Host Data
savemark.q Save current map markers
scr-s-f.q Scramble Ships Names Off, restore the original names
scr-s-o.q Scramble Ships Names On, generating and random name
shadow.q Shadow (former Hide Ship Names)
starbase.q Starbase Building
swapf4.q Swap F4 and ESC in Control Screens
target.q TARGETx.DAT I/O
taxes.q Taxation Scripts
tty.q PCC on a TTY (text console)
vis.q Visualize Stuff, EchoView-like
wpmove.q Modeless Waypoint Moving
Back to PCC page

auto.q - Auto Tasks

Download this script

Some useful auto tasks I use. Feel free to add more and/or improve the existing ones.

Needs PCC 1.1.2 or later.

autoexec.q - Stefan's Autoexec Script

Download this script

This is my actual autoexec script, for your inspiration.

Version: February 2005.

       --Stefan Reuther

bum.q - Cloaked Ship Detection using `bum'/`btm'

Download this script

First attempt to detect (cloaked) ships. If a cloaked ship orbits your planet, and your have the FCode set to `bum', the cloaked ship will receive your money, and you'll know that there was a cloaked ship (because the money is gone). This also works with ships and `btm'. This is a (simple) attempt of doing this in a script. To use,

  • start the routine `BumDet' from the planet, or `BtmDet' from a ship. Either, by invoking it from the calculator, or by making an auto task.
  • ensure that this subroutine gets to see your final turn. Unfortunately, this can't yet (PCC 1.1) be automated. Right now, PCC runs sleeping scripts when it starts. So either reload your turn into PCC and exit again just before MakeTurn, or manually run all `BumDet' processes (using the process manager) just before you exit PCC;
  • you'll get a notify message when this routine thinks it succeeded;
  • to end this, kill the process in the process manager, or change the friendly code.

History:

  • 03/Dec/2000 First version, after an idea by Piotr Winiarczyk
  • 08/Apr/2002 updated for PCC 1.0.18; include tax gain in predictions
  • 03/Jul/2002 works with `btm', too
  • 09/Aug/2002 don't get confused by growth
  • 25/Aug/2002 fixed stupid typo on BtmDet

Needs PCC 1.0.18 or higher.

cargo.q - Cargo Transfer `Macros'

Download this script

This script contains some small `macros' for cargo transfer. See the source code for comments on how to use them.

checker.q - Simple Turn Checker

Download this script

Load your game into PCC and use the command `Check' to locate (possible) errors in your turn. They'll be reported to the console. What to be an error worth reporting can be configured with the `Check.WarnLevel' variable; with `Check.Correct' set, this program will also attempt to fix some of the errors. The preferred way to set those variables is by placing appropriate assignment statements in your autoexec script:
  Load "checker.q"
  Check.WarnLevel := 2
Note that these assignments only work after the script was loaded.

To check only a single object, go to its control screen and do `RunHook CheckShip' or `RunHook CheckPlanet', respectively.

To add your own checks, write appropriate subroutines and make them known to the checker framework using `On CheckShip Do...' etc.

comment.q - Comment Timestamps

Download this script

This module provides comment timestamps. It attaches a marker of the form "|T:<turn number>" to every comment you change. For example, I often write to my ships what they're doing: "get fuel", "bring clans". Sometimes I forget clearing the comment after performing that task. This module brings a reminder -- when the comment is too old, it is probably stale.

Hacked together on a snowy 24th of March 2002 by Stefan Reuther. Needs PCC 1.0.17 or later.

explmap.q - Explore map tracker

Download this script

This script is supposed to keep tracking on newly scanned planets with the add-on ExploreMap With ExploreMap players receive each turn a new XYplan.dat storing old and new planets. New planets occur based on the scanner settings in EploreMap and can be tricky to follow. The script verifies for each planet if a special property-tag from a former turn exists. If not (this means the planet was detected in the current turn) explmap adds a marker (green cactus) to the starmap for at least one turn. Additionally, a message box will inform the player how many new planets have been scanned. [18/Nov/2006: Tom Wuerzer]

fborg.q - Show Hyperjump Routes ending at a Planet (including 3 Ly square GravityWell)

Download this script

Best use: press "b" and "Ctrl-b" in the StarChart to draw HyperJump routes into the Map or delete them

fixtow.q - PCC Sample Script -- Fix Towees

Download this script

To try this function:

  • load the script, by using [Alt-R] on the race screen, or `Load "fixtow.q"' on the console
  • type `FixTowees' at the console. This will set all ships which are being towed to Warp 0, so they won't accidentially break the tow.

Alternatively, do `cc GAME PLAYER /rk Load "fixtow.q"'

goto.q - Go to object - quickly

Download this script

This module provides functions to quickly go to particular objects by id, in the form of convenient short wrappers around `UI.GotoScreen'. For fast typists, this is much faster than the conventional way (using the search function or manual browsing).

  • sh shows a ship on the ship screen/starcharts
  • pl shows a planet on the planet screen/starcharts
  • sb shows a starbase on the starbase screen
  • fl shows the fleet for a ship on the fleet screen
  • go looks for ships first, then planets

Each function takes an argument, which it will try to use as an ID. If the argument is a string, then the functions search for the first ship or planet with that string in its name, preferably yours.

hidename.q - Hide Ship Names

Download this script

This script will name ships using boring fake names. You can use this in anonymous games to avoid that enemies recognize you (as a person) by your ship naming style.

Fake names will be made up of a prefix (`hn.Prefix') followed by several random digits. Outside PCC, only these fake names will be seen.

To use this, simply load it from your gameinit/autoexec file. The rest is automatic. Like all automatisms, this one's dangerous:

WARNING: if you load your turn with scrambled names, and your invoke PCC 1.0.14 or before without this script loaded, the original names will be lost! For a safer, semi-automatic version, use Manuel's `scr-s-o.q'.

To stop this and restore the normal names, do the following:

  • load your turn as usual
  • from the console, execute the command `hn.Terminate'
  • exit PCC
  • remove the `Load' command from your gameinit/autoexec file, else name scrambling will start again.

History:

  • 04/Aug/2001 first version
  • 02/Oct/2001 updated for PCC 1.0.15

load.q - Load Minerals for Fighter / Torpedo Building

Download this script

This provides a ship command `LoadForBuild' that will load the amount of minerals for building that ship's ammunition.

You'll be prompted for the number of torps/fighters you want. The input line will be pre-initialized with the maximum number this script thinks is possible. Enter the desired amount and hit Enter.

  • 14/Jul/2002 by Stefan Reuther
  • 10/Aug/2002 refuse to run on freighters
  • 14/Jan/2005 added ability to load arbitrary type (for suppliers). This is not on a key, use 'LoadForBuild 0,1' to call it.

Needs PCC 1.0.18 or above.

marker.q - Display Markers at Current Position

Download this script

This will list all markers (with comment) from the current position in a list box. In particular, it will list all ships that exploded at a certain place. Just choose that place at the starchart and press Ctrl-L.

Hacked together by Stefan Reuther, after a request by Lucas di Pentima, on 01/Oct/2002.

Needs PCC 1.1.1 for the Listbox() construct.

move.q - Advanced "MoveTo" command

Download this script

Use these until we have a graphical "auto waypoint" editor:

  • AMoveTo moves to a location specified by a string
  • AMoveSeq moves to up to 9 of such locations, in the specified order
  • AMoveLoop builds a loop of up to 9 such locations

These commands are to be entered at the console. For example,
  AMoveLoop "p15", "p494"
makes the current starship move back and forth between planets 15 and 494. To stop that loop, use the process manager and terminate the appropriate process.

nextturn.q - PCC Sample Script -- What will I have here next turn?

Download this script

To try this function:

  • load the script, by using [Alt-R] on the race screen, or `Load "nextturn.q"' on the console
  • on a planet, type `NextTurn' at the console. This will print the amounts of minerals you'll have here next turn to the console.

Known problem: if ship A tows ship B, and both have their waypoint set to "here", B's cargo will be counted twice. A possible solution would be a helper property "this ship already counted".

22/Feb/2001 Native taxes fixed; added some comments.

plist.q - PList support for PCC

Download this script

Hullgen generates the short hull names for a given ship list. This module sets the short names for the other starship components, from PList (2.31b if anyone cares). Load it from autoexec.q/gameinit.q.

(Except for someone who tells it the short names, PCC does not need other special support for nonstandard ship lists)

Requires at least PCC 1.0.18.

psmap.q - Experimental PostScript Map Printer

Download this script

This generates a postscript map from the current game data. You can then print that map on a normal PostScript printer. The PS output is almost readable so you can adjust it if you wish.

Usage: call `ps.Print'. This will ask you for an extent and a file name. It will print the requested region around the current position in the map/control screen. To print the whole map, go to the map center and use the Extent you also configured in the chart options.

13/Oct/2002 by Stefan Reuther

revive.q - Revive PCC

Download this script

This script attempts to save and restore the current status of PCC between sessions. Hence you can exit PCC, do something else, and when you start PCC again, you'll be where you left off last time.

In addition, this script provides a hook "NewTurn" which is run when a new turn has started.

This script is far from complete.

Usage: put `Load "revive.q"' in your autoexec/gameinit script. The rest is automatic. By default, this will also load the saved status when the turn number changed. If you don't want it to do that, do `Revive.LoadOldTurn := False' after the load instruction.

History:

  • 22/Aug/2001 basic infrastructure
  • 15/Dec/2001 save starchart position
  • 08/Dec/2002 save selection
  • 11/Dec/2002 "NewTurn"

Note 15/Feb/2005: the NewTurn hook is now provided by the PCC core. You do no longer need this module to use that hook. However, PCC's core.q contains provisions that these two do not interfere (it makes sure the hook is called only once during each load).

savehost.q - Save Game as Host Data

Download this script

This saves your turn as host data. You can then run host.exe on it. It attempts to restore as much as possible of the original data. Of course, this is not always possible: missing information is guessed (minerals on enemy planets, fcodes) or set to zero (enemy ship cargo).

This code is ALPHA, read, it worked correctly on the test data set I tested it on, and Host 3.22.020 / PHost 3.3d no longer complains.

Usage: either, run this on the command line using PCC or CCS:
  cc GAMEDIR PLAYER /rk Load "savehost.q"
and answer the questions. This will save the specified game data as host files in the current directory. Alternatively, fire up the PCC GUI, load the game, and type at the console
  Load "savehost.q"
  sh.Interactive
This does the same, but also asks for the target directory, and is a bit more colorful ;-)

Right now, this can only read one player's data. If you have multiple RSTs, it would be nice to merge them, but right now this is not completely possible. For planets, PCC's history does a pretty decent job, but for ships and bases, we can't currently help.

This script requires PCC 1.0.14 or later. File I/O has bugs in 1.0.13 which crash PCC. This is also a neat benchmark & crash test for PCC ;)

Author: Stefan Reuther <Streu@gmx.de>

  • August 2001: initial version
  • March 2002: support for score blankers. Tried it with PHost -- works :)
  • 03/Jul/2002: PCC 1.0.19 also supports console input
  • 14/Jul/2002: fixed starbase storage

savemark.q - Save current map markers

Download this script

This script generates another script that can be used to regenerate your current map drawings. One example use is sharing these drawings with a friend, or transferring them from one game to another.

Instructions:

  • use Alt-R on player menu to run this script
  • you will get a second file requester asking for the name of the file to save to (look close to not accidentally overwrite an important other script!)

On the receiving end, run the script you just generated using Alt-R. You will now have the old drawings here, too.

January 2006 by Stefan Reuther

scr-s-f.q - Scramble Ships Names Off, restore the original names

Download this script

Author: Manuel Fernandes Alonso
Version: 1.0.1
Date: 28/09/2001 (DD/MM/YYYY)
History: 1.0 Initial version
          1.1 The program verifies if the ship is own, to avoid restore captured or destroyed ships

Run this after unpack the trn and prior other utilities

scr-s-o.q - Scramble Ships Names On, generating and random name

Download this script

Run this script before the last maketurn. This will scramble the ship names, saving the original names to a file. To unscramble them again, use `scr-s-f.q'.

Author: Manuel Fernandes Alonso
Version: 1.0
Date: 07/08/2001 (DD/MM/YYYY)
History: None

shadow.q - Shadow (former Hide Ship Names)

Download this script

NEW ABILITY: individual fakenames

Set your own fake names for ships to get your enemy confused. if the ShadowName is empty, the normal script of hidename will take control shipnames, for the case you just forget one new build ship to set in Shadowmode ;-))

This script will name ships using boring fake names. You can use this in anonymous games to avoid that enemies recognize you (as a person) by your ship naming style.

Fake names will be made up of a prefix (`hn.Prefix') followed by several random digits. Outside PCC, only these fake names will be seen.

To use this, simply load it from your gameinit/autoexec file. The rest is automatic. Like all automatisms, this one's dangerous:

WARNING: if you load your turn with scrambled names, and your invoke PCC 1.0.14 or before without this script loaded, the original names will be lost! For a safer, semi-automatic version, use Manuel's `scr-s-o.q'.

To stop this and restore the normal names, do the following:

  • load your turn as usual
  • from the console, execute the command `sn.Terminate'
  • exit PCC
  • remove the `Load' command from your gameinit/autoexec file, else name scrambling will start again.

History:

  • 04/Aug/2001 first version
  • 02/Oct/2001 updated for PCC 1.0.15
  • 11/Jan/2004 modified for individual fakenames (done by Tom Würzer)

starbase.q - Starbase Building

Download this script
  • WantBase: Counts everything on incoming ships, and everything on the planet, and tells you how much more to ship in to build a starbase. Derived from the NextTurn.q Sample Script.
  • BaseReady: Looks at each of your planets, and tells you which ones are ready to build.

Note: This script uses TaxYield from Taxes.q

Author: Eric Wald
Version: 1.0
Date: 12 April 2002

swapf4.q - Swap F4 and ESC in Control Screens

Download this script

Some people like it better if [ESC] gets to the map, not to the race screen. This script swaps [ESC] and [F4] on control screens.

Usage: simply put `Load "swapf4.q"' in your autoexec.q.

target.q - TARGETx.DAT I/O

Download this script

This (silly?) script creates TARGETx.DAT files. Note that this does not directly affect display in PCC.

  • `tgt.ReadFile "name"' loads a target file into memory (i.e. TARGET3.DAT)
  • `tgt.Generate' generates targets for all ships seen on the map.
  • `tgt.WriteFile "name"' writes a target file.
  • `tgt.Clear' clears working space.
  • `tgt.Merge' merges all targets from all players.

Possible uses:
  tgt.ReadFile 'my\ally\target1.dat'
  tgt.Generate
  tgt.WriteFile dir & 'target' & My.Race$ & '.dat'
creates a file containing all the ships from your turn, and those which your ally sees. When you exit and reload PCC, you'll see them all.
  For i:=1 To 11 Do
    Try tgt.ReadFile dir & 'target' & i & '.dat'
  Next
  tgt.WriteFile dir & 'target' & My.Race$ & '.dat'
snarfs all targets from the other players into your file. `tgt.Merge' does approximately this.

(note that in the above examples, `dir' should be `System.GameDirectory').

taxes.q - Taxation Scripts

Download this script
  • SafeTax: Brings Amorphs to 96 HP, everyone else to 71 HP. Must be called from Planet context.
  • GrowthTax: Safe taxes only under specific conditions, Designed to let your populations grow if they can. Must be called from Planet context.
  • SafeTaxAll and GrowthTaxAll: Calls the appropriate tax model on each of your planets. Also calls Tax.Corrections at the end, if you have defined it.
  • TaxYield: Calculates the number of megacredits a planet will generate, and stores it in Tax.Native and Tax.Colonist (shared variables, not planet properties).
  • Tax.PrintYield: Calls TaxYield and prints its values to the console.
  • CalcGrowth: Calculates the population growth for a planet and stores it in Natives.Growth and Colonists.Growth (planet properties, not shared variables).
  • GrowthReport: Outputs to a file the expected and actual growth of each of your planets.

Author: Eric Wald
Version: 2.0
Date: 12 April 2002

tty.q - PCC on a TTY (text console)

Download this script

This module provides a text console for PCC. Basically, it shows a prompt and lets you enter commands. You can enter as many commands as you wish, confirm each one with [Enter]. [ESC] exits the console. So, if you want to run PCC on the command line, do
    cc GAME PLAYER /rk Load "tty.q"

In addition, this module provides a few commands that are useful on the console. In GUI mode, you should use the GUI equivalent, so there's no point in loading this file into the GUI.

  • `ListPlanets "expr"': lists all planets matching expr. For example, `ListPlanets "mined.n > 100"' lists all planets with more than 100 kt Neutronium. This function contains a pager (stops every 24 elements); if your screen has more lines, you can configure that using the variable `tty.PageSize'. In GUI mode, use the search function instead of this function.
  • `ListShips "expr"': does the same for ships.
  • `pl id': go to planet #id. All the following commands will apply to that planet. This is like opening a control screen. `pl' without parameters goes back to "top level".
  • `sh id': likewise for ships.

In addition, the following shortcuts exist:

  • `..': when on a planet/ship, this goes back to top-level
  • `?a, b, c...': shortcut for `Print'. Unlike the normal PCC console, the result of an expression you enter is not automatically displayed. You have to print them explicitly.

This module requires PCC 1.0.19. Older PCCs do not support input in text mode.

  • 03/Sep/2003: some clean-up; added pager
  • 07/Jan/2003: help; this script is now part of CCS
  • 05/Jan/2003: fix: empty lines would crash this when entered in ship/planet level
  • 28/Apr/2002: first version

This script uses only variables named `tty.XXX' to avoid clashes with user variables.

Todo: some sort of input history, with `bang' commands, would be nice. Somehow like in csh/bash.

vis.q - Visualize Stuff, EchoView-like

Download this script

This is a simple attempt of implementing something similar to EchoView's visualisation feature for PCC. The basic principle: you enter an expression yielding a number, and PCC displays bars of appropriate size at every planet/ship. PCC already has something similar built in (object labels).

There are 4 "layers" of visualisation, the appropriate bars are displayed in northeast, northwest, southwest and southeast of the labelled object.

The main entry point is `Visualize'; it'll prompt for necessary parameters. Although not required by the rest of the code, the user interface fixes the ranges at 100..10000, that is, a value less than 100 will not be displayed; values larger than 10000 will yield a maximum-size bar (40 pixels, vis.Height).

Besides being useful, this script demonstrates some funky uses of the `Eval' statement ;-)

  • PCC does not (yet) have array variables, so we simulate them by generating variable names
  • Variables containing "a, b, c" are split into pieces by passing them to subroutines as parameters

Author: January 2002 by Stefan Reuther

Needs PCC 1.0.16 (older ones don't have Eval).

wpmove.q - Modeless Waypoint Moving

Download this script

This allows you to move the waypoint of a ship in the ship screen without explicitly entering scanner-move mode or such. Arrows move by 10 ly, Ctrl-Arrows move by 100 ly (or prefix argument); Ctrl-Enter locks onto next planet.

The script integration of PCC is not yet perfect, as you can see with this script: when you are locked at a ship in the starchart and hit Shift-Arrow, it'll move 10 ly (because our routine is called and can not tell apart Shift-Arrow from just Arrow). In older PCC versions (below 1.0.19) it is even worse. PCC II will be better. I promise :-)

  • 18/Apr/2002 first version
  • 01/Oct/2002 now works (sort-of) in the starchart

This page has been generated automatically from the script headers.


Go to
[ Planets Command Center | My VGA Planets Page ]

Stefan Reuther
If you wish to redistribute stuff from these pages, please play by the rules: Copyright information.