Skip to content

Batch Syntax

Gruftikus edited this page Nov 23, 2014 · 11 revisions

The batch files are normal text files (like shell scripts or bat-files), therefore any text editor can be used for creating and changing these files. Comments might be added to the batch file by “;” (like in W$-ini-files) or with “#” (like in unix).

The batch file is structured in sections, marked in squared brackets:

[sectionname]

The part which is read by lltool is by default marked with [lltool]. This can be changed by the command line, i.e.:

lltool [other_section] filename.mpb

Sections are followed by a list of commands. Each command might be followed by options. Each option starts with “-” and is optionally assigned to a value with “=”. The value itself can be included in quotation marks, this must be done if the value includes spaces (like -name=”a b c”).

Flags and Variables

The batch file syntax supports flags, which can be used to control the runtime behavior of the batch execution. The flags can be defined either in the lltool command line or inside the script. If a values is assigned to a flag, it works as a variable.

Flags can be defined (and changed by the command SetFlag):

SetFlag -name=flag1 -value=blabla

or with the command line:

lltool flag1=blabla filename.mpb

Flags (as variables) can also be used in commands: a flag with the name flag1 can be used with a $ (like in a unix shell script) to replace the text by the value of the flag. E.g. $flag1 will be exchanged by the value of the flag, in our case blabla. Therefore, to use a real $, it must be preceded by a backslash: \$.

Example:

Echo -text=$flag1

Flags can be used in boolean options of other commands, like:

SetFlag -name=myopt -value="-rgb"
ImportMap -filename="source.bmp" $myopt

(N.b. that does not work with options requiring a value)

To unselect a flag, one can use:

SetFlag -name=flag1 -unselect

Calculations (Win-Version only)

Calculations can be done with $(...). The expression inside the bracket is evaluated using the same syntax like equation algorithms. The output format of the result can be controlled with the variable _flag_format which has the same syntax like the format specifier in C.

Example:

SetFlag -name=_flag_format -value="02.0"
ExportMap -filename="$_worldspace_id.$($_quad_x * 32).$(32 * $_quad_y).32.bmp"

Conditions

Each command might be preceded by a test on a flag condition, which is invoked by an “@” followed by the flag itself. A simple test on the validity of a flag is:

@flagname MyCommand...

A test on a disabled flag is (negation) is indicated by an additional “!”, like:

@!flagname MyCommand...

The test on a specific value of a flag can be realized as follows:

@flagname=value MyCommand...

Flags can be combined, like:

@flag1 @flag2 .....

Blocks

Commands can be nested in curly brackets (like in C or C++). Example:

@flag1 {
     "other commands"
}   

Iterators

Some of the commands work as iterators, which means that the command (or block) after is executed multiple times. This feature is used to form loops (e.g. looping over quads or regions of the map)

Clone this wiki locally