Category: Script / Strings
Since engine version: 1.0 OC


Composes a string of several values. To do this, text is scanned for placeholders starting with '%' which are then replaced by the parameters.
The general syntax for these placeholders is:
%[length][.precision]typeExcept for type all fields are optional. Type specifies the data type of the parameter to be expected. It can be one of the following values:
Type Meaning
d Whole number (int)
x Whole number (int), hexadecimal representation (0123456789abcdef)
X Whole number (int), hexadecimal representation (0123456789ABCDEF)
i id (with ids, length and precision parameters do not apply)
s String
v Any. Primarily useful for debugging.
Length specifies the minimum number of characters used to display the value. If the value is shorter, the display is padded on the left with space characters, or with zeroes if there is a '0' before the length specification.

The meaning of the precision field varies with the data type: for integers (d) it specifies the minimum display length (the number is padded with zeroes at the beginning); however for strings (s) it specifies the maximum number of characters to be displayed.


string Format(string text,  ...);


String into which to insert values.
Values to be inserted.


Log(Format("Hello, %s.You have %d Clonks!", GetPlayerName(0), GetCrewCount(0)));
Displays "Hello Twonky, you have 3 Clonks!" (names vary).
Log(Format("'%3d'", 1));
Displays: ' 1'
Log(Format("'%i'", GetID(GetCursor())));
Displays (e.g.): 'Clonk'
Log(Format("'%3.2d'", 5));
Displays: ' 05'
Log(Format("'%.2s'", "test"));
Displays: 'te'
Log(Format("'%03d'", 12));
Displays: '012'
Sven2, 2001-11