NML:Error

From GRFSpecs
Revision as of 11:34, 21 August 2011 by FooBar (talk | contribs) (content of nml r1625)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The general form of an error statement is:


error(level, message[, extra_text[, parameter1[, parameter2]]])

where level is the severity of the message and one of NOTICE, WARNING, ERROR, FATAL. The message can be either a custom defined string which can contain up to two parameters or it can be one of the pre-defined strings which already have translations. The first {STRING}-code will always be replaced by the NewGRF name. The second {STRING}-code will be replaced by the value of 'extra_text'. Extra_text can be a string defined in the language files or it can be a literal string, in which case it cannot be translated. You should only use a literal string in those cases where you are sure it doesn't have to be translated, for example to provide a version string like "0.7.0".

name actual text Contents of extra_text
REQUIRES_TTDPATCH "{STRING} requires at least TTDPatch version {STRING}" version string
REQUIRES_DOS_WINDOWS "{STRING} is for the {STRING} version of TTD." Windows] Palette type
USED_WITH "{STRING} is designed to be used with {STRING}" switchname + value, e.g. "multihead 0". This is designed to be used for incompatible settings that you can check via ttdpatch_flags.
INVALID_PARAMETER "Invalid parameter for {STRING}: parameter {STRING} ({PARAM})" extra_text should be the parameter number written out as string. {PARAM} is replaced by parameter1. filled in.
MUST_LOAD_BEFORE "{STRING} must be loaded before {STRING}." NewGRF name
MUST_LOAD_AFTER "{STRING} must be loaded after {STRING}." NewGRF name
REQUIRES_OPENTTD "{STRING} requires OpenTTD version {STRING} or better." version string
string(STR_MY_ERROR_MESSAGE) (user-defined string) The message-string can use the code {STRING} up to 2 times, the first usage will be replaced by the NewGRF name and the second usage by 'extra_text'. After 2 {STRING}-codes you can include up to 2 {PARAM}-codes that will be replaced by the contents of parameter1 and parameter2.

For example:

 error(NOTICE, USED_WITH, string(STR_REGRESSION_CARE));
 error(FATAL, string(STR_REGRESSION_ERROR), string(STR_ANSWER), 14, param[1] + 12 * param[2]);