Command-line Features

This file is intended to give a brief summary of the "smart" commands available in the Python/Tk empire client.

Each of the following commands may be entered as if they were a normal empire server command. The client will automatically recognize these commands and handle them locally, where applicable.

In addition to commands that are typed in on the command line, commands can also be specified in three built-in configuration files. The file, "first.emp" is executed the first time the client connects to the server, "start.emp" is run every time the client starts up, and the file "connect.emp" is run each time a connection is made to the server.

Important Change! Previous versions of the client had a command known as "sync". This command has be renamed to "rdb", and its syntax has been altered!


Basic commands:

rdb - Refresh client databases.
This command is used to keep the sector/ship/plane/nuke/etc databases synchronized. When this command is issued dump/sdump/pdump/ldump/lost commands will be buffered to the server. Empire 4.x timestamps are used to ensure only recently updated values are returned. It is a good idea to use this command instead of manually running dump yourself.

At one time, the server had a bug that caused empire updates to modify sectors and units without updating the timestamps. To circumvent this problem, 'rdb' was expanded to use the form 'rerdb'. A "re-refresh" will force this command to ignore timestamps and dump the entire database. It should not be necessary to use this form of the command.

Additionally, the command rdb (or rerdb) may contain a suffix that contains any combination of 'epslno'. 'e' stands for sector dump, 'p' is a plane dump, 's' is a ship dump, 'l' is a land dump, 'n' is a nuke dump, and 'o' is a lost dump. When these selectors are specified, only the corresponding dumps will be sent. This is useful when it is know which databases have changed, and it is not desirable to dump all the databases. For example, you might specify 'rdbel' to synchronize just sectors and land units.

During processing of the outgoing command queue, if two or more rdb commands are buffered simultaneously, the client will automatically ignore the first database refresh. Since the first refresh is contained entirely within the second, it doesn't make much sense to send the first. When this behavior is not desired, the rdb command can be suffixed with a "P" flag. This prevents the first rdb command from being ignored.

null <cmd> - Run command with no output.
Send <cmd> to server, but don't display its output on the command-line. The output will still be parsed by the internal parsers. For example, "null map *" will update the graphical display without flooding the output window.

<cmd1> ; <cmd2> - Multi-Command line.
This command allows multiple commands to be sent on the same line. For example, "map * ; bmap *" will send "map *" followed by "bmap *".

<cmd> | <program> - Send output of <cmd> to the system command <program>
<cmd> > <file> - Store output of <cmd> in new file called <file>
<cmd> >! <file> - Store output of <cmd> in file named <file>, overwriting an existing file if any.
<cmd> >> <file> - Store output of <cmd> at the end of the file <file>
The above commands redirect the output of an empire command.

execute <file> - Send the contents of <file> to the empire server.
runfeed <program> - Send the output from a system command <program> to the empire server.
These commands allow server commands to be collected in an external source. When processing the commands, lines beginning with a "#" are considered comments and are silently ignored. All other lines are interpreted as client or server commands.

The "execute" command may be abbreviated to as short as "exe". This command is intended to mimic the effects of the similar server based command.

alias <cmd> <newcmd> - Generate a definition for a simple alias.
All future invocations of <cmd> will automagically be altered to send <newcmd> instead. Optionally, the alias may contain special substitution characters. When evaluating, the sequence $* is substituted with the command's arguments, $X is substituted for the Xth word of the command's arguments ($0 will be replaced by the command name), and $$ is replaced by a single $ character. For example, the command "alias mvoe move $*", makes mvoe function exactly like move.

To make an alias permanent, place the alias command in the start.emp file. There are also many examples of aliases in this file.

Note: There is no protection from infinitely recursing aliases. If an alias calls itself it will probably end up hanging the client!

Note2: When in burst mode aliases may also be evaluated for sub-prompts. Because of this, it is a good idea to plan out aliases that don't easily conflict with common empire sub-prompts.

burst <cmd> - Send commands unsynchronized.
The burst command can be used to send a series of commands to the server without synchronizing the output. Synchronizing output can incur a significant amount of latency. By "bursting" multiple commands simultaneously, a significant improvement can be made to the overall connection speed. Unfortunately, when multiple commands are "bursted", it becomes possible for a command to accidently answer the preceding command's sub-prompt. This utility is most powerful when it is applied to commands whose sub-prompts (or lack of sub-prompts) can be entirely predicted.

Note: The internal parser will parse bursted commands!

Simple examples:

burst tele 4;Hi there.;What's up?;.
This command will burst the 4 lines of data ('tele 4', 'Hi there.', 'What's up?', and '.'). Because telegram has predictable sub-prompts, it is safe to assume that the above will tele 4 with the included message.
burst nation;version;update;map *
This command will send the four specified commands simultaneously. Because nation, version, and update never take sub-prompts, and because map has a predictable sub-prompt - It is safe to assume that these commands will execute properly.

For a more in depth analysis, see the burst section in the TIPS file. There are also a number of examples in the default start.emp file.


Tk Window commands:

What follows is a quick summary of the Tk based commands. Many of these commands are further documented in the gui.html file.

wind <cmd> - Output command to Tk Window.
Send <cmd> to server, pop-up a new window on the desktop, and redirect all output from the command to this window. For example, the command "wind info Products" would send that 20 page manual to its own window with its own scrollbar. This window can then be left up for future reference; it will not interfere with sending and receiving of additional empire commands. An unlimited number of these output windows may be used simultaneously.

wread - Graphical correspondence tool.
The internal parsers automatically store incoming telegrams, incoming announcements, and outgoing telegrams. Sending this command will pop up a graphical telegram window which allows reviewing and responding to these messages.

Note: If you are short on disk space, you may have to use this tool to delete old telegrams and announcements from the database. Since the client automatically stores old messages, the database can become rather large over time.

Map - Open an additional graphical map window.
This command will pop up an additional graphical map in its own desktop window. An unlimited number of these map windows may be used simultaneously, and each map window can have its own origin and scale.

cshow <'ship'|'land'|'plane'> - Hack for show command.
This command will send "show X build; show X cap; show X sta" and rearrange the output into multiple columns. A Tk window will pop up with the resulting formatted display.

Login - Re-open the login window.
This command forces the Tk interface to re-open the Login window. When connected to a server, the login window may be used to force a disconnect. When not connected to a server, the Login window can be used to alter database, server, and country information.

Sect <sectors> [<selectors>] - Highlight specified sectors on main map.
This command locally emulates the empire server's sect command. It can be used to mark sectors on the graphical map that meet a provided empire selector. It is intended to work similar to the server based "sect" command.

NOTE: This command uses the internal database to determine which sectors apply. If the database is not synchronized, the results will not be correct!

The arguments to sect work in the same manner as the foreach command which is described below.

Optionally, you may run the Sect command with no arguments at all to erase the highlights from any past Sect commands.


Smart commands:

eval nation|version|<sect> <cmd> - Evaluate an expression for a sector.
This command allows a command to contain python expressions that are evaluated using the nation database, the version database, or a sector database.

NOTE: This command uses the internal database. If the database is not synchronized, the results will not be correct!

<sect> is a sector designation of the form x,y. (Note, if you wish to run a programmable-command on many sectors, use the foreach command.) This sector's database is referenced when evaluation the rest of the command.

<cmd> is an empire command that contains an arbitrary number of python expressions embedded within it. The python expressions must be enclosed within [ and ] characters (the square brackets). These python expressions are evaluated using a namespace from the specified database. The names of the variables are the same as their corresponding empire selectors, and similar to the empire selectors they may be abbreviated (for example, both 'newdes' and 'new' are equivalent). In addition to the standard empire selectors, there are two included aliases: sect (A string containing the sector's x,y pair), and dist (A string containing the dist_x,dist_y pair). See the selectors section of the TIPS file for more information.

An example:

eval 0,0 move mil [dist] [mob/2+1-mil] [sect] ; anti [sect]
In this example, enough mil is pulled in from sector 0,0's dist center so that the maximum number of mil usable in an anti command is available. The anti command is then executed.

foreach <sectors> [<selectors>] <cmd> - Run given command on specified sectors.
Similar to the PEI foreach command, this command takes a sector range, an optional ?<var>=<val>&... selector, and then runs cmd on each sector that meets the requirements.

NOTE: This command uses the internal database. If the database is not synchronized, the results will not be correct!

<sectors> and <selectors> are similar to those on the empire server. <sectors> can be a range of sectors (x1:x2,y1:y2), an '*' to specify all sectors, or an empire range of the form '#X'. <selectors> is a series of variable conditions that may be specified using the form "?<var><cond><var>" where <var> is a either a constant or a valid empire variable, and cond is one of '=', '<', '>' or '#'. Any number of selectors may be specified by appending them with a '&' character in-between. See the empire selectors section of the TIPS.html file for advanced information.

<cmd> is a string that will be parsed in the same manner as the eval command.

An example:

foreach * ?dust=1&d_dist=0 move d [sect] 1 4,7
The above command moves 1 dust to sector 4,7 from all sectors that have exactly 1 dust and have no dust threshold.

A more complex example:

foreach * ?mil<50 move mil [dist] [50-mil] [sect]
The above attempts to resupply all sectors from their respective dist centers so that all sectors have a minimum of 50 mil.

An insane example:

foreach * move gun [10>gun and dist+' '+`10-gun`+' '+sect or sect+' '+`gun-10`+' '+dist]
The above moves guns around so that exactly 10 guns are in every sector. Sectors that have more than 10 guns in them move guns to their dist centers; sectors with less than 10 guns move guns from their dist sectors.

nova <civ|mil> <start sector> [to sector] - Explore adjacent wilderness sectors.
The start sector has to be an owned sector that contains mobility and civs/mil. If [to sector] is specified, it must be an owned sector that is adjacent to unowned wilderness. (If [to sector] is not specified then start sector must be adjacent to unowned wilderness.) Explore commands are then generated from the start sector to all adjacent wilderness sectors. No best path is calculated.

WARNING: This command is experimental! Do not use it in important situations. (But it might be useful in blitzes.) It uses the internal database, which has to be synchronized.

mmove <commodity> <source sectors> <min level> <mobility> <dest sectors> <max level> - This command produces a best-path multimove.
Invoking mmove will generate a series of commands that attempt to move the commodity specified by <commodity> from the sectors in <source sectors> so that there is <max level> of the commodity in all the sectors in <dest sectors> such that all source sectors will not go below <min level> of the commodity and not go below <mobility> mobility.. Phew..

Ok, an example:

mmove food * 60 40 * 60
This moves food from sectors with more than 60 food to sectors with less than 60 food. At least 40 mobility will be left in every sector.

mmove civ #1 768 80 #2 ?new#+ 768
This will attempt to move civs from sectors in realm 1 that have more than 768 civs to sectors in realm 2 that have less than 768 civs and are not road sectors. At least 80 mobility is left in each sector.

The mmove utility is a contribution from Ulf Larsson. WARNING! This code is still experimental! Please use with discretion.

Mover <commodity> <amount> <sector list> - Issue a multi-stage move.
The Mover utility moves amount of commodity from the first sector of sector list to the second sector of sector list, to the third sector, fourth sector, and so on until the commodity resides in the last sector of sector list . The purpose of this utility is to move commodities around using way-points as mobility sinks.

The amount field has a special meaning in this utility:

Note: This command is still in its infancy. Both it and the graphical move utility, which uses this command, should be used with a little caution. Also, this command has no support for moves that cause enemy interdiction. If interdiction occurs, it will probably not do what you want.

Predict <sector> - Get predictions for a sector.
This command displays information about the effects of an update on a sector. On a graphical interface, this output is also available in the Sector Census Window. Currently, it supports population growth statistics, starvation warnings, worker information, and new efficiency data.


Information commands:

define - List all online commands
You may obtain a list of all client commands that are currently available by sending the command "define".

out - Debugging tool - dumps database.
Don't run this - it is only useful for debugging. (And not very useful at that.) It will send the entire database to the empire console.