Block file

From WarThunder-Wiki
Jump to: navigation, search

A block file (*.blk) is a file holding relatively small pieces of data for the game in text form and is used in various places where mostly power users and modders are encouraged to make changes or add content to the game. WarThunder itself also stores settings in the config.blk file in the game’s root directory.

While most data is stored in binary formats, which are faster to read by computer programs and usually smaller than text formats, the latter has the benefits of being human readable and editable with a basic text editing program instead of complex editing software. Every text file format such as HTML needs to provide enough structure for a computer program to recognize and itemize the contained data while giving the human editor a degree freedom to e.g. add comments or insert blank lines for better organization.


The below excerpt from a config.blk illustrates the basic structure of a block file. There are assignments of values ("medium") to named items (cloudsQuality) of a specific data type indicated by a short code (t) and named groups such as "graphics" which provide some structure by wrapping other assignments and groups inside curly braces.



The names of data items and groups are implied by the game. There are usually either example files highlighting the available options or pages in this Wiki about them. Their exact spelling and casing is important or the game will silently ignore the provided values and resort to defaults. Speaking of which, the default values are usually sensible and if they suit you, allow you to omit some lines from your block file to keep it slim. Some block files expect you to mention a name multiple times to create an array of values, like the line drawing block in user-made sighting reticles:

   line{ line:p4=0.35, -1, 0.35, 0; move:b=no; }
   line{ line:p4=115, +10000, 117, 0; move:b=no; thousandth:b=yes; }

The name is followed by a colon ":" and a short code for the expected data type.

Code Meaning
t Text enclosed in "" which is often free form, but sometimes used to present the user with a set of predefined, named options, e.g. "high", "medium" and "low".
b A boolean value can be set to yes or no. Alternatively true and false can also be used.
i An integral number, positive or negative.
r A real number.
p2 Comma separated list of two real numbers, often a 2D point.
p3 Comma separated list of three real numbers, often a 3D point.
p4 Comma separated list of four real numbers.
c A color represented by four comma separated integers from 0 to 255 for red, green, blue and alpha (opacity).

The assignment continues with an equals sign and the value in an appropriate form. Text must be enclosed in double quotation marks (""). Numbers must be given in decimal base with optional leading zeroes and sign. Real numbers use the dot (.) as the decimal point. Boolean values are either yes/true or no/false.

Assignments may be terminated by a semicolon (;) and they have to be if the line does not end after the assignment. Two examples:

 x:r=3; y:r=5
 person { name:t="John Doe"; age:r=50; }

While you can put several assignments on one line you may not break up a single assignment into multiple lines. Line breaks are allowed around curly braces and assignments. Additional white-space is allowed between all elements, but not between parts of a number (i.e. + 5).


Block files allow two types of comments, line end comments and block comments known from many programming and scripting languages. A line comment is placed at the end of a line of text and starts with two slashes (//). A block comment can span multiple lines or be interspersed into a line and is enclosed in a slash and asterisk combination like so: /* comment */. The game will for the most part interpret a block file as if the comments were cut out. Some valid comments:

   text { text:t="X"; pos:p2=0./*works*/35,0 /* position in screen units */; align:i=0; } // draws an X

The game is not be able to digest coordinate lists on multiple lines though. Neither with nor without comments:

 pos:p3=3, /* x
 */     4, /* y
 */     5; /* z */

Game aspects dealing with block files