These are functions to alert the user to problems in the way the newGRF file is loaded, e.g. not in the right order, not the right TTDPatch or OpenTTD version, or because of wrong parameters, as well as to deactivate incompatible other newGRF files.
| Function | Description |
| deactivateset(<List::Label>) | Deactivate other newGRF files |
| error(<Byte>, <Language-ID>, <Byte>, <String>) | Throw error message (and terminate) |
Normally, newGRF sets should use skipif(EXIT, ...) to deactivate themselves, if they find that other incompatible newGRF files have been loaded.
However, when new sets come out, it is often not feasible to change all existing sets so that they can detect the new set. This function therefore allows the newGRF set to deactivate older sets with which it is incompatible.
Parameter is a list of newGRF-IDs which should be deactivated.
Note that it is invalid to attempt the deactivation of already active newGRF files. You can only prevent files lower down the newgrf(w).cfg from becoming active later. Therefore, you must check that none of the newGRFIDs in this list are active already using an appropriate skipif() check. If the deactivation of an already active set is attempted, the current set is considered invalid and will be disabled.
If you attempt to deactivate a set that isn't loaded, nothing happens.
To handle the cases of incompatible sets being loaded and activated earlier, you can either attempt to overwrite all their settings and graphics, or simply deactivate this set in turn.
In principle, there can be four cases and the newGRF file must be able to handle all of them properly:
error(<Byte>, <Language-ID>, <Byte>, <String>)
| Parameter | Description |
| Severity | Severity level |
| Language-ID | Language-ID |
| message-id | What kind of message to show |
| message | Custom message text |
This parameter sets how severe the message is, and acts accordingly:
| Severity | Meaning | Prefix | Action taken | NOTICE | Notice | (none) | continue loading grf file | WARNING | Warning | ERROR | Error | "Error: " | FATAL | abort loading of grf file, and do not attempt again until TTDPatch is restarted |
Normally, function error() is ignored during initialization of the newGRF. If <severity> is set to ABORT, a fatal error will be applied even during initialization. This can be useful to prevent errors due to invalid sprites during initialization. Note that this only works properly since 2.0.1 alpha 66, for earlier versions the error popup that is shown is corrupted if bit 7 is set.
Messages are shown with a "/!\" sign in the GRF Status window. The first fatal message during each activation is shown as a red popup box as well.
For the language-IDs to be used, see here.
This parameter defines what kind of message to show. There are following options:
| Message-ID | Content |
| 00 | " requires at least TTDPatch version " xx |
| 01 | " is for the " xx " version of TTD." |
| 02 | " is designed to be used with " xx |
| 04 | " must be loaded before " xx "." |
| 05 | " must be loaded after " xx "." |
| 06 | " requires OpenTTD version " xx " or better." |
| FF | Custom message, use text from <message>>/td> |
Message-ID 06 is available since OpenTTD r11330. This message should only be used when variable PLATFORM in skipif() results to 1 (OpenTTD).
In all messages (built-in and custom), the filename of the newGRF file precedes the message and xx is replaced by the content of <message>.
Note that if several grf files attempt to show fatal error messages, only the first message is actually shown at the moment since TTD does not have a queue for the red error popups. All others will however be shown in the GRF Status window.
// check for CargoSet active? skipif(4,GRFACTIVE,+,GRF_CARGOSET) // yes, overwrite it // check for CargoSet inactive? skipif(1,GRFACTIVE,-,GRF_CARGOSET) // yes, deactivate it skip(2) error(WARNING,ALL,FF,"Deactivating CargoSet." CRLF "Must be loaded before DB Set XL.") deactivateset(GRF_CARGOSET)