Strings

From OpenTTD

Jump to: navigation, search
HAL (Hardware Abstraction Layer)

Audio
Music
Graphic

Window System

Using the Window System
Events used by the Window System
Colour codes that exist in OpenTTD

Patches

HOWTO - Add a patch option

The Map / Scenario

Understanding the Dynamic Landscape Array
Understanding the SaveGame Handler
HOWTO - Create good Scenarios
HOWTO - Add New Town Name Generators

The actual simulation

Vehicles
Using Orders
Pathfinding
Ratings
Train Acceleration

Language and Strings

Using OpenTTD Strings

Multiplayer

The Core Interface

Starting a Server
Connecting to a Server
Using the list of LAN/Internet Games

The OpenTTD TCP Protocol
The OpenTTD UDP Protocol
HOWTO - Debug desyncs

Ingame Console

The Console Window
Using Console Scripting
HOWTO - Add Functions/Commands to the Console
HOWTO - Add Variables to the Console
HOWTO - Direct Variable Access using ICONSOLE_VAR_POINTER
OpenTTD Console Commands
OpenTTD Console Variables
Development History

This page is about the strings/language from a developers point of view. When you want to translate, please look at Format of langfiles for a more in-depth article about translating and how to support for example genders and plurals.

You add a new string by adding a line to "english.txt". This should happen at the place where it belongs with the other strings around. Keep in mind that sometimes OpenTTD uses special code for the numbering of strings. For example you SHOULD NOT put anything else in between the dates: "1st", "2nd"... "31st". These strings are not called by their name, but iterated through from within the code with a counter. Keep this in mind!

[edit] Adding Strings

You add a string by giving it an identifier, something starting with "STR_" then a number of spaces later a colon ":" and then the string itself. For example:

STR_01A1_IS_GETTING_VERY_OLD   :{WHITE}{STRING} {COMMA} is getting very old

The strings enclosed in "{}"'s are special character strings that are interpreted by the game. As you might have guessed, "{WHITE}" gives the string a white colour.

[edit] List of special strings

Font and color (default size is medium)
Command Description
{TINYFONT} switch to tiny font
{BIGFONT} switch to big font

{BLACK}  {WHITE}
{RED}    {GREEN}
{BLUE}   {YELLOW}
{ORANGE} {PURPLE}
{GRAY}   {BROWN}
{SILVER} {GOLD}
{CREAM}  {LTBLUE}
{DKBLUE} {DKGREEN}
{LTBROWN}

Change the colour of the string, or the part of string until overridden by another colour to this colour.
Special characters
Command Description
{} Go to the next line
{NBSP} non-breaking space
{{} {
{POUNDSIGN} £
{YENSIGN} ¥
{COPYRIGHT} ©
{UPARROW}
{DOWNARROW}
{RIGHTARROW}
{SMALLUPARROW} small ↑
{SMALLDOWNARROW} small ↓
{CHECKMARK} (a checkmark)
{CROSS} (an X, used for closing windows)
{TRAIN} icon of a train
{LORRY} icon of a lorry / truck
{BUS} icon of a bus
{PLANE} icon of a plane
{SHIP} icon of a ship
Formatted Numbers
Command Params Description
{NUM} 1 show a 32-bit signed integer number, e.g. 1600
{COMMA} 1 show a 32-bit signed integer number with a thousands separator, e.g. 14,000
{CURRENCY} 1 number as a currency, e.g. € 230,000
{CURRCOMPACT} 1 short version of currency (used in graphs)
{DATE_TINY} 1 tiny date version, e.g. 01-07-2004
{DATE_SHORT} 1 short date version, e.g. February 2004
{DATE_LONG} 1 long date version, e.g. 25th February 2004
{FORCE} 1 show number as force, e.g. 1500kN
{POWER} 1 show number as power, e.g. 6000HP
{VELOCITY} 1 show number as speed, e.g. 120km/h or 195mph
{VOLUME} 1 show number as volume, e.g. 1,000 litres
{VOLUME_S} 1 show number as volume, e.g. 1,000L
{WEIGHT} 1 show number as weight, e.g. 1,000 tonnes
{WEIGHT_S} 1 show number as weight, e.g. 1,000T
{CARGO} 2 show number as cargo, e.g. 950 tonnes of Coal
{SHORTCARGO} 2 number with cargo units, e.g. 950 tonnes
Formatted Strings (given an index)
Command Params Description
{STRING} 1 get a string from an index
{STRING1} 1 Same as {STRING}
{STRING2} 2 get a string with 2 parameters
{STRING3} 3 get a string with 3 parameters
{STRING4} 4 get a string with 4 parameters
{STRING5} 5 get a string with 5 parameters
{COMPANY} 1 get the company-name pointed to by this index
{PLAYERNAME} 1 get the player-name pointed to by this index
{STATION} 1 get the station-name pointed to by this index
{TOWN} 1 get the town-name pointed to by this index
{WAYPOINT} 1 get the waypoint-name pointed to by this index
{VEHICLE} 1 get the vehicle-name pointed to by this index
{SKIP} 1 Use up a parameter but do nothing with it
Special commands
Command Params Description
{SETX} 1 Set X position of text, useful for scrolling
{SETXY} 2 Set XY position of text, useful for scrolling
{P} 0 Plural modifier
{G} 0 Gender modifier
{REV} 0 OpenTTD revision string

[edit] How to use these?

As you have seen before, you have to put these special modifiers into the string itself. Let us revisit the above example:

STR_01A1_IS_GETTING_VERY_OLD   :{WHITE}{STRING} {COMMA} is getting very old

Both "STRING" and "COMMA" are variables. You set them up by calling the appropriate "SetDParam(uint n, uint32 v)" function. So for this one you would do:

SetDParam(0, _vehicle_type_names[v->type - 0x10]);
SetDParam(1, v->unitnumber);

Only after that you call the appropiate draw function, for example:

DrawStringRightAligned(x, y, STR_01A1_IS_GETTING_VERY_OLD, colour);

Both parameters of "STR_01.." have been set up, and you will get the info nicely on your screen. Good luck!

Personal tools