Trainz/AM&C/config.txt files

Fundamentals
All assets must have a  file to be placed in Trainz, else they aren't an asset. Also called a 'config file' or just a 'config', the  by any name contains essential information about the asset, most importantly its  =  and including its, kuid number, , , ,  tags, etcetera (and their ) and also some optional but non-essential historical tags (prototype railroad, company), authorship, licensing, and ownership information tags such as creator, organization, contact email, 3rd Party website, etc.&mdash;all the 'defines' which allow the asset's folder to be a self-defining AND SELF-DOCUMENTING Trainz compatible asset. Well, except a config change record, or ways to review successive changes. In the forgoing, several times we encapsulated the label ' ' to emphasize two important points. ALL data in Trainz is defined and manipulated by a KEYWORD -- LEGAL VALUE relationship. In computer science, the (or Legal Values) are an list constrained by membership in the enumerated data type. For example the type Binary (also often termed 'Boolean') is an enumerated type with just two legal values: { binary: 0, 1 }, which notation *'{'+term+':'+list of values+'}' is read 'the set Binary has the members zero and one'. The list of values, is also known as an enumerated list, in this example of length two, with two permissible values. Anything not on the list, is illegal, and will generate a Trainz Fault, and a related error message, as well as prevent you from committing the asset into the database. The prevention of committing a faulty asset into the database began somewhere in the corresponding to their overlap in TBVs (and so capabilities) of TS10 and TS09. Knowing what's-what, and does what, when it's appropriate and when not is the subject &mdash;this page is dedicated to removing the mystery from all the 'defines' which a studious glance at the more formal N3V Wiki can leave even a veteran software professional perplexed and daunt or likely even dismay the novice. Let us put you on a firm path to grasping Trainz Basic Knowledge (TBK).

Some General points on config.txt files
Many of the problems with faulty assets are caused by simple typing, nesting, or spelling mistakes in their  files. A spin-off effect of this type when the nesting of quotes is incorrect, usually because of missing or extra quote-marks. When this is true CM/CMP when opening the file will attempt to fix what it finds and this creates a string or series of bad tag name errors when it attempts to parse the text paragraph as keywords and values. This gives a cascade of faults (loads! 20+), generally inserts whitespace and the resultant text is even more badly quoted&mdash;the text looks like Armageddon hit the page for a bit of it. This usually occurs inside the larger blocks of text like or. Fortunately, these 'unhelpful assists' can be hand edited in a few moments to be corrected. (This 'blow up auto-fixing' is better action than with TRS2004 and earlier Trainz&mdash;everything below such typos used to disappear! Vaporware!)

Other faults, particularly after V3.3 are due to changes in the s and enforcement of what is since V2.8 and is now called the &mdash;which data set always initializes the body of any and all config.txt files and sets up the system of self-defining assets. Based on some of those TBS values, other data is then added to configure the asset, including references to other included asset component files such as images, s, texture.txt files, and Level of Detail *.LM files. The starting point for that self-definition is the role of the TBS and the definition and referencing of all elements in the asset is the role of it's config.txt file. Bottom line, virtually all asset repairs require changes to the config.txt file&mdash;and it is a rare error which needs another fix which does not!

Tips and Tricks
/>Open the config.txt file from it's folder, then immediately back to the folder. /> />
 * 1) Since the config files are the heart of a self-defining asset, while new to asset fixing and updating, or well after as a good practice, when opening the asset for edit in CM:
 * 2) Method 1: ( opens asset then puts you into the folder)
 * 3) before editing the config file duplicate it using 'Save As' 
 * 4) or first use Windows to make a copy (select,, select the folder, ). Use  to rename the file Config.org.txt... or leave the name alone with the (copy) inserted in the filename by Windows.
 * 5) then and only then open the original config file for editing.
 * 6) Method 2: (Fastest: may depend upon your text editor) <br
 * 1) The config.txt file should still be highlighted (selected) so next press  and insert .org or .v2-4, etc. in front of the .txt extension. (Trainz will not tolerate unknown data file types when validating and committing the asset, so only the legal text based file types, .txt extension or .htm, can be used.)
 * 2) When you're done,  back to the editor.   Notepad++ will complain (notify you) the file is missing, asks if it should retain the file in memory. Say Yes. Windows Notepad won't have noticed it missing. 🇨🇴 <br
 * 1) A programmer's editor with multiple tabs able to open many files; search and replace in regular expressions, replace in multiple files, and/or ability to compare files is highly recommended., , and  are all available as freeware (and time available, will be covered in this Wikibook) and each has most of these useful features.  At the least, Notepad++&mdash;which can also search and replace across end of line characters, which is very useful for compounding multiple kuids into a comma separated list (CSV) acceptable to CM will be featured in many a Trainz screenshot. <br
 * 1) Target your Downloading and take small bites! When downloading early on in your Trainz experience, target your download carefully in small groups of assets, no more than a couple of screenfuls.
 * 2) After the download, view the group in Main View, Copy All, and transfer the CSV list into a spreadsheet like Open Office Calc. You may have to clean up a few cells when there are commas in titles (s, but you'll have two columns of sortable data as a log file.  Get in the habit of saving as soon as you put data down and tidy it up before leaving the Application. You might loose power or worse forget!
 * 3) If you keep that as a running log, appending as you go, add in some type data in another column, it makes a handy list for a  to route build with per the next paragraph.  Of course you need not limit such copies to downloaded content, any main view listed item can be highlighted and added!
 * 4) Copy the kuids only column, take it to Notepad++, and Search from   and Replace (SAR) with ">,<kuid" to quickly obtain a CSV with your entire download.
 * 5) However, note your filter is already showing only those kuids, from the download+show in Main View, so save that in 'Last Download'.
 * 6) As practice of a useful technique, Add a second kuid search field to the 'in place' filter and separate the two with an  filter modifier. Apply, and the list should show nothing if you got the whole list!
 * 7) Since you've saved it, you can now address any faults AND keep the same display order by ANDing it with, and only the Faulty one's on that list will appear.  Other faults not on the list won't&mdash;this let's you focus on what's important now, if you got greedy and suddenly have a whole lot of faulty content. Work your way through them by finding the routes+sessions you are most interested in, and use the ANDing technique to just fix the things you need for that goal referencing against a kuid CSV of their 'combined dependencies'.  Note: Using A saved filter with , , and  can help quite a bit in narrowing down, selectively looking at, or otherwise organizing your asset management tasks.   Practice, Practice, Practice--this technique will save you a lot of time once it becomes yours.   All filter techniques which eliminate the clutter (not showing content on the DLS is perhaps the most useful) along with Skill in selecting the screening criteria will to hone in your search for what you need or are looking for, all save time.   Another useful technique is Inverting your selections... Assume you have thirty assets showing as obsolete in that route you want to try. Highlight the group,  AND select , the display will show just your highlighted assets and their relatives. Now,  AND select  and voila' &mdash; all the updates are highlighted and you can drag the lot into the download helper in a block (or...   AND select &mdash;which will add them for you and start an immediate download!
 * 8) To be continued

Text editors
files are plain text files, though the oldest assets may have line one contain a BOM (Byte Order Mark) Code. They should be edited with a non-formatting program such as Windows Notepad, ConTEXT, Notepad++, Programmer's Notepad, or other non-word processor kind of &mdash; many of them also known as programmers editors.

One such text program is ConTEXT, which provides syntax highlighting when used with Wulf/Wulf9's TPR's syntax file post syntax files. You will need to register at the above link (TrainzProRoutes) to be able to download the syntax files. ConTEXT will also show matching brackets, which is very helpful when troubleshooting, and it should be noted is the text editor N3V Games has mentioned in a few TrainzOnline wiki articles.

Many examples in this book will use the  programmers editor with multiple tabs (files handling), search and replace  in files and across open files, regular expressions (REGEX) searching and SAR processing, SAR across line breaks (newlines or line feeds), and so on. These features go a long way in overcoming dumb output from or in fixing faulty content.

2014-0417-1 List of 982 DAVESNOW assets crossloaded new TS12 to old F~TS12
 * example 1A

Anhaen, AnhaengerLeer, Anhaen 1, Appliances Industry Corp, Arcon Mk V, ATLS CONTROLLER, Notepad++ can turn the above (or 890 Lines like that) into a CSV KUID list like the following in less than 2 minutes and 30 seconds with practice using REGEX SARS: ,,,,, The same CSV can be obtained in 30-60 seconds using a open spreadsheet and a scratch file ( in Notepad++. Another Notepad++ TAB can be used to keep a running list of such groups for future filter use.  ( DO  centralize your Trainz document storage place in only one main directory--looking for something months later is Soooo very annoying!)   A kuid field can literally hold thousands of CSV kuids, so such bundles have a great deal of value, if saved with a heading.   so a  can navigate save to save up or down!
 * example 1B
 * example 2

Correct Spelling is a precise need
Tag keywords must be spelt correctly, and the correct syntax must be used when specifying the parameters of each or  value(s). Since a computer program will be interpreting the contents, precise accuracy is required.

Curly Braces rules
Curly braces  and   are used to designate the starting and ending points of the contents of those tag pairs of groups of associated data pairs which require multiple lines. These are known as Containers and a special container type, the in large part determines how the data in the config.txt file is processed (and so which errors will happen if specified wrongly.) Every open curly brace must have a corresponding closed curly brace, and ALL 'Open Curly Braces' MUST ALWAYS be prefixed by  ( or s in other words). Some tags can be nested in which case structures such as  are permitted, with the preceding whitespaces proviso.

Kuids and Kuid2s
must be specified using one of the following formats:
 * ,(where the number of digits may vary)
 * note by definition,
 * note by definition,

A kuid or virtually any specification in the config.txt file that is not text double-quoted already can optionally be enclosed in a pair of double-quotes, for example: , trainz-build    "2.9"

Tags, Kinds, and Container Names
The following tags are mandatory:
 * Every value in Trainz is part of a data pair &mdash; keycode called a or  name and data
 * 1)  contain multiple definitions, including mixes of data types such as decimals, integers and strings but which are associated with one another.
 * 2) Kinds are containers which are unique to a particular type of asset, whereas a container is a collection of related data elements which is needed by more than one type of KIND.

Some Common Errors In config.txt Files

 * Mismatched curly braces.
 * Any non-spacing character immediately followed by an open curly braces.
 * Any non-spacing character immediately followed by an open angle bracket, except in HTML where it is allowed.

For the items in the following table, an error will only occur if the item is used as a keyword. Inside text strings such as descriptions any spelling, spacing and punctuation can be used.

TRS 2004 and TRS 2006
In TRS2004 and earlier versions of Trainz, after editing a  file it is necessary to delete the   file, otherwise Trainz will use the old version of the file. This is only required if the  file being modified is in the   hierarchy. If you are editing files in the  hierarchy, the   file does not need to be deleted.
 * Special circumstances...

For TRS2004 users, the Trainz Objectz free third-party utility can be used for scan installed assets for common errors in their, and optionally automatically correct some of the errors. This inspired Content Manager's development.

For TRS2006-SP1 and TC users, CMP provides good error-checking but be careful, mess up the brackets and you may find anything following disappears. So making a backup before editing is recommended.