Adding the Native Automatic Running Numbers system to a traincar

From TrainzOnline
Jump to: navigation, search

Introduced with Trainz: A New Era, the Native Vehicle Running Numbers system provides a built-in method of automatic running numbers for traincars (locomotives and rolling stock) in Trainz, using a range of numbers specified in the config.txt file to assign running numbers to the traincar when placed. The system also supports multiple-unit numbering (ie where each vehicle in a multiple-unit set will either have the same number, or can increase the number by an amount set in the relevant tags; see Adding to an asset.

The numbers can still be changed in-game via the Properties window as per any other traincar in Trainz.

The visible numbers on the traincar will still use the existing Alpha-Numbers system.

Contents

Scripted assets

Prior to Trainz: A New Era, many assets used scripts such as 'NumberIt', 'ARN' (Automatic Running Numbers), and other custom scripts to assign the running numbers to the traincar when placed. The script is the '.gs' file found in some Trainz assets; a single script file is normally used in Trainz, and as such may do multiple different things.

In many cases, these scripts allowed effectively unlimited number ranges, which caused the script to take a long time to load or process the running numbers. This could cause issues with Trainz loading the asset. Trainz: A New Era will limit how long the script can take to load, and hence if it takes too long it will time out and not load.

For Trainz: A New Era and onwards, it is recommended to use the Native Vehicle Running Numbers system to assign numbers to your traincars. This will help avoid script errors (causing numbers to not load, and possibly other functions on the traincar to not operate), and reduce the script load on Trainz itself.

The Vehicle Running Numbers Container

The Native Vehicle Running Numbers system is configured with some very simple tags, specifically the Vehicle Running Numbers container.

For detailed information on the tags in this container, see Vehicle Running Numbers container, including information on multiple unit train setup.

The container, when entered into the config.txt file will appear as

vehicle-running-numbers
{
running-numbers          "1-5,7,9-11"
}

The container allows you to enter individual numbers, as well as number ranges. Number ranges are specified with the lower end of the range first (inclusive), then a hyphen, then the higher end of the range (exclusive). Individual numbers, or multiple ranges, are separated by a comma (,). The above example will give the numbers 1, 2, 3, 4, 7, 9, 10.

Adding the Native Vehicle Running Numbers system to an asset

It is very simple to add the Native Vehicle Running Numbers system to an asset by following these steps. Please note, these steps do not cover updating assets to Trainz-Build 4.2, or adding alpha-numbers to an asset.

1) Open the asset for edit in Content Manager (Trainz Content), and open in explorer/finder (right click on the asset, go to 'open', then click on 'in explorer' or 'in finder')

2) Double click on the 'config.txt' file

3) Now that the config file is open, the first step is to ensure that your asset's Trainz-Build number is set to 4.2 (TANE release) or higher. You should always use the minimum Trainz-Build number that you can test the asset in (ie if you only have access to TANE SP2 or SP3 for testing, then you should use build 4.5).

3-A) Changing the Trainz-Build number on an existing asset will enforce the TANE level error checking on the assets, placing stricter Level Of Detail requirements on assets, and correct material configuration (in particular where a material with the same name is shared between different meshes) and naming.

4) The next step is to enter the vehicle-running-numbers container into your asset. This is placed at the 'root level' of the config.txt (ie not inside any other containers). Copy and paste the following into your config.txt:

vehicle-running-numbers
{
running-numbers          ""
}

5) You will now need to enter the number range for your traincar between the quote marks. For example:

running-numbers "1,5,20-50,75-100"

6) Save your config.txt file, and close the text editor.

7) Go back to Content Manager, right click on your asset, then click on submit.

8) Now try placing your traincar within Surveyor (do not place in Driver in TANE, as the running numbers may not automatically load due to a known bug in TANE). When placed it should automatically receive a number within the specified number range.

Updating an asset with scripted running numbers

If you are updating an existing asset with scripted running numbers, then there are a few things to be mindful of. The following steps are a general guide, as different script methods used may function differently, and require different steps.

1) Open the asset for edit in Content Manager, and open in explorer/finder (right click on the asset, go to 'open', then click on 'in explorer' or 'in finder')

2) Double click on the 'config.txt' file

3) Now that the config file is open, the first step is to ensure that your asset's Trainz-Build number is set to 4.2 (TANE release) or higher. You should always use the minimum Trainz-Build number that you can test the asset in (ie if you only have access to TANE SP2 or SP3 for testing, then you should use build 4.5).

3-A)Changing the Trainz-Build number on an existing asset will enforce the TANE level error checking on the assets, placing stricter Level Of Detail requirements on assets, and correct material configuration (in particular where a material with the same name is shared between different meshes) and naming.

4) The next step is to remove the old config tags for the scripted running numbers. These will vary, but will generally mention 'numbers' or similar. For example, the 'NumbertIt' script has the following tags:

numberit-75134
{
numberit_prefix                     "94"
numberit_min                        "0000"
numberit_max                        "9999"
}

This entire container must be removed.

5)Once removed, the next step is to enter the vehicle-running-numbers container into your asset. This is placed at the 'root level' of the config.txt (ie not inside any other containers). Copy and paste the following into your config.txt:

vehicle-running-numbers
{
running-numbers          ""
}

5) You will now need to enter the number range for your traincar between the quote marks. For example:

running-numbers "1,5,20-50,75-100"

6) Save your config.txt file, and close the text editor.

7) Go back to Content Manager, right click on your asset, then click on submit.

8) Now try placing your traincar within Surveyor (do not place in Driver in TANE, as the running numbers may not automatically load due to a known bug in TANE). When placed it should automatically receive a number within the specified number range.

TIP: Most scripts should not need the script edited after doing this, although if you know how to it is recommended that the running number code be removed from your asset's script, so as to reduce the resources used.

If the script only provides automatic running numbers, then the entire script (gs file) and the 'script' and 'class' config tags can be removed.

In-game use

When used in-game, the numbers will be automatically assigned. You can change the number on a traincar in Surveyor (or Driver) by following these steps:

  1. Open the Trains Tab
  2. Select the 'Properties' tool (the ? icon)
  3. Click on the traincar you wish to change; this will open that traincar's Properties window
  4. Click on the running number shown
  5. Enter the number you want the traincar to have
  6. Click the checkmark in the running number window
  7. Click the checkmark in the 'Properties' window
  8. You should now see the new number shown on the traincar

Alternatively, you can assign a new random number by following these steps:

  1. Open the Trains Tab
  2. Select the 'Properties' tool (the ? icon)
  3. Click on the traincar you wish to change; this will open that traincar's Properties window
  4. Click on the ( Automatic ) or ( Manual ) text to the right of the running number; this will cause a new number to be automatically generated.
  5. Click the checkmark in the 'Properties' window
  6. You should now see the new number shown on the traincar

Return To

Personal tools