GSText Class Reference

Class that handles all text related functions. More...


Public Member Functions

 GSText (StringID string,...)
 Generate a text from string.
void SetParam (int parameter, Object value)
 Set the parameter to a value.
GSTextAddParam (Object value)
 Add a value as parameter (appending it).

Static Public Attributes

static const int SCRIPT_TEXT_MAX_PARAMETERS = 20
 The maximum amount of parameters you can give to one object.


Detailed Description

Class that handles all text related functions.

You can define a language file in lang/english.txt, in the same format as OpenTTD does, including tags like {BLACK}, {STRING1} etc. The name given to this string is made available to you in GSText, for example: GSText.STR_NEWS, if your english.txt contains: STR_NEWS :{BLACK}Welcome {COMPANY}!

In translation files like lang/dutch.txt you can then translate such strings, like: STR_NEWS :{BLACK}Hallo {COMPANY}! When the user has the dutch language selected, it will automatically use the translated string when available. The fallback language is always the english language.

If you use parameters in your strings, you will have to define those parameters, for example like this:

 local text = GSText(GSText.STR_NEWS);
 text.AddParam(1); 
This will set the {COMPANY} to the name of Company 1. Alternatively you can directly give those arguments to the GSText constructor, like this:
 local text = GSText(GSText.STR_NEWS, 1); 

Constructor & Destructor Documentation

GSText::GSText ( StringID  string,
  ... 
)

Generate a text from string.

You can set parameters to the instance which can be required for the string.

Parameters:
string The string of the text.
... Optional arguments for this string.


Member Function Documentation

void GSText::SetParam ( int  parameter,
Object  value 
)

Set the parameter to a value.

Parameters:
parameter Which parameter to set.
value The value of the parameter. Has to be string, integer or an instance of the class GSText.

GSText* GSText::AddParam ( Object  value  ) 

Add a value as parameter (appending it).

Parameters:
value The value of the parameter. Has to be string, integer or an instance of the class GSText.
Returns:
The same object as on which this is called, so you can chain.


Generated on Sun Apr 1 13:49:00 2018 for OpenTTD Game API by  doxygen 1.5.6