digits(x, y, format, font, factor, var);

Number or text display within a panel.

Parameters

x Horizontal distance to the panel's upper left corner, in pixels.
y Vertical distance to the panel's upper left corner, in pixels.
format

Format parameter, either a number, char*, or a non-Unicode STRING*. The integer part of the number gives the total number of characters used by the variable, the fractional part gives the number of displayed decimals (e.g. 5.1 = 5 characters total, consisting of 3 integer digits, the decimal point, and 1 decimal). If the number is negative, leading zeros will be displayed.
Alternatively, a C-style format string can be given. It defines the format of the displayed number plus a leading and trailing text and is composed the following way (also see examples):
"[text1]%[flags][width][.precision]f[text2]"
[text1] = Optional leading text.
[flags] = Optional one or more of the following characters:
   - = Left align the number within the given field width. Default: Right align.
   + = Prefix the number with a + or - sign. Default: Sign only for negative values.
   0 = Leading zeros are added until width is reached. Default: Blanks are added.
   blank (' ') = Prefix positive numbers with a single blank. Default: No single blank.
   # = Forces the number to contain a decimal point. Default: Decimal point only if digits follow it.
[width] = Optional minimum number of characters displayed.
[.precision] = Optional maximum number of digits after the decimal point.
[text2] = Optional trailing text.
The '%..f' represents the variable, and can be omitted for displaying only text, but no number. The total length of the format string must not exceed 100 characters, and the format string must not be a number without any alphabetic character. A '%s' represents a string that is given for the var parameter. For displaying a percent sign, use '%%'. A more extensive description of C-style format strings - used also for the printf function - can be found in any C/C++ book.

font TrueType or bitmap character set for the display. Either a predefined FONT, or A6.6 a font filename or Truetype font name with size and style (like "Arial#24bi") can be given. If '*' ist given, the engine standard font is used.
factor The content of the variable is multiplied by the given factor before displaying. The result is not limited to the normal variable range of -999999..+999999, thus allowing for the display of huge numbers.
var Global var, object parameter, or  LC  a predefined global STRING* object to be displayed. In that case, "%s" represents the STRING content in the format parameter.

Remarks

Examples:

FONT* digit_font = "digit.pcx";

PANEL* aircraft_pan =
{
  digits(0,0,4,digit_font,1000,player.skill10);
  digits(60,0,4,digit_font,1,player.skill11);
  digits(120,0,4,"digit2.pcx",1,my_height);
  digits(10,10,5.1,*,1,time_step); //   5.1 = 3 integer and 1 decimal digit
  flags = SHOW;
}

//Examples for format strings (the variable x = 123456.789 is displayed in the standard font):
digits(0,0,"%.3f",*,1,x);          // "123456.789"
digits(0,0,"%.0f",*,100000,x);     // "1234578900"
digits(0,0,"%010.0f",*,1,x);       // "000123457"
digits(0,0,"Vol: %.1f ltr",*,1,x); // "Vol: 123456.8 ltr"
digits(0,0,"Just a text",*,0,0);   // "Just a text"
digits(0,0,0,*,1,tex_name);	// "brickwall"
digits(0,0,"Texture Name: %s",*,1,tex_name);	// "Texture name: brickwall"

See also:

PANEL, pan_setdigits, pan_setstring, pan_setpos, pan_setcolor

► latest version online