Cities: Skylines

Cities: Skylines

Random Train Trailers 2.4.2
 This topic has been pinned, so it's probably important
Acc3ss Violation  [developer] 23 Feb, 2017 @ 5:35am
Config structure
The xml config files are called RTT-Default-Definition.xml and RTT-Definition.xml.
The in-game editor
There is now an in-game editor, open it by clicking the train icon in the main toolbar (should be somewhere in the bottom right). You can use all the features in the mod with it without having to edit xml files by hand. You might still find the explanation of the settings on this page useful.


RTT-Default-Definition.xml
This file is located in the mod directory and contains the configuration for the vehicles in the Random Train Trailers Collection. It is generated automatically when you first use the mod. For this reason it contains some empty tags. There should be no reason to edit this.
To overwrite a vehicle that is defined in here just redefine it in RTT-Definition.xml or with the in-game editor.

RTT-Definition.xml
This file is located in the game's local user directory. It is generated the first time the mod is used. Any custom configurations that you want to make should go in here. The in-game UI edits this file as well.

You can access either file easily by going into the mod options and clicking the "Open user/default config directory" buttons.

Debugging
To make it easier to debug your configs enable the full logging option in the mod options. Search for anything with the prefix "Random Train Trailers" in the game's output_log.txt. It will also include a formatted overview of all loaded vehicle configs.

Adding vehicles
This randomizes the trailers of a vehicle using only its own trailer assets.
<Vehicle name="NS 2200 Mixed Cargo" chance="94"/>
name is the name of the vehicle. Can be just the display name or the full asset name.
chance is the chance of randomizing the trailers for the vehicle as a percentage. Must be a whole number. Defaults to 100 (always randomized).

Other options are:
useDefault defaults to true and indicates if the trailers the asset comes with should be used for the random selection. Set this to false if you want to use a fully custom trailer list.
start is the index of the first trailer that may be randomized. Defaults to 0 (the first trailer). Setting this to 1 will skip 1 trailer, 2 skips 2, etc.
end indicates how many trailers on the end are not randomized. Defaults to 0. 1 will leave the last trailer non-randomized, 2 the last 2 etc.

Custom trailer lists and blacklisting
If you want to have more control over what trailers get used in the random selection process you can specify a list of trailer yourself, like so:
<Vehicle name="516681588.TRAXX Cargo (CAPTRAIN)_Data"> <Trailers> <Trailer name="684700650.Trailer6" weight="8"/> <Trailer name="684700650.Trailer2" weight="10" invertProbability="100"/> </Trailers> <LocalBlacklist> <BlacklistItem name="516681588.Trailer0" /> <BlacklistItem name="516681588.Trailer1" /> </LocalBlacklist> </Vehicle>
A trailer tag can have the following attributes:
name is the name of the trailer asset.
weight is the weight of the trailer in the random selection, the default is 10. Make it less to lower the chances of the trailer being selected, higher to increase this chance.
invertProbability is the chance of the trailer being inverted (reversed) when spawned as a percentage. Must be a whole number, defaults to 0 (not inverted).

This vehicle did not have useDefault set to false, so all of its own trailers can be used in the random selection. But what if we don't want that? To stop trailers from being included you can add them to the local blacklist (trailer blacklist for that vehicle).
A blacklist item simply contains the name of the trailer you don't want to be included.

Using another train's trailers
<?xml version="1.0" encoding="utf-8"?> <TrailerDefinition> <Vehicles> <Vehicle name="NS 2200 Tanker Train" useDefault="false"> <Trailers> <Trailer name="527827092.Trailer1" /> <Trailer name="527827092.Trailer2" /> </Trailers> </Vehicle> </Vehicles> </TrailerDefinition>
The snippet above is an example of an RTT-Definition.xml that replaces the NS 2200 Tanker Train's trailers with those of Tim the Terrible's Farm Freight Express.
useDefault="false" stops the mod from using the NS 2200's own trailers and the trailer list includes 2 trailer models from the farm freight express. (527827092.Trailer0 is a trailer with the model of an engine, so we don't include it because it would look silly)

Multi trailers
There are cases where trailers need to appear in a fixed order, like some container cars. To allow this you can make a so called multi trailer, just like a regular trailer, but slightly different.
<Vehicle name="516681588.TRAXX Cargo (CAPTRAIN)_Data" chance="94"> <Trailers> <Trailer name="Double K Line Intermodal" weight="8"> <SubTrailers> <Trailer name="516681588.Trailer0" /> <Trailer name="516681588.Trailer1" /> </SubTrailers> </Trailer> </Trailers> <LocalBlacklist> <BlacklistItem name="516681588.Trailer0" /> <BlacklistItem name="516681588.Trailer1" /> </LocalBlacklist> </Vehicle>
As you can see, a multi-trailer is created by specifying a list of sub-trailers for a trailer. In this case the name of the multi-trailer is irrelevant and only used for debugging. Sub-trailers are regular trailer tags and can include an invertProbability.

When a multi-trailer is picked by the random selection, all of its sub trailers will be spawned in the order given in the config file.

The sub trailers' assets are added to the blacklist in this case because they look bad when not spawned in the correct order.

Collections
For some consistency in all this randomness you may want to make groups of trailers which fit together, like container or boxcars. This way you can randomly have either a randomized container or closed goods train and not the frankenstein express. (unless you want this of course)

To do this we have TrailerCollections, which go in the Collections tag. An example:
<?xml version="1.0" encoding="utf-8"?> <TrailerDefinition> <Vehicles> <Vehicle name="NS 2200 Tanker Train" useDefault="true"> <Trailers> <Trailer name="UK Freightliner Intermodal Loaded" collection="true" weight="5" /> <Trailer name="NS6516_NS_Falns.Trailer1" /> <Trailer name="NS6424_DB_Kls_Hout.Trailer0" /> <Trailer name="NS1616-Sahimms-8-24.Trailer0" /> </Trailers> </Vehicle> </Vehicles> <Collections> <TrailerCollection name="UK Freightliner Intermodal Loaded"> <Trailers> <Trailer name="20/20/20 Hamburg + 40/20 Maersk"> <SubTrailers> <Trailer name="869739118.TrailerClass66FreightlinerIntermodal0" /> <Trailer name="869739118.TrailerClass66FreightlinerIntermodal1" invertProbability="100" /> </SubTrailers> </Trailer> <Trailer name="20/0/20 Maersk + 40 MSC"> <SubTrailers> <Trailer name="869739118.TrailerClass66FreightlinerIntermodal2" /> <Trailer name="869739118.TrailerClass66FreightlinerIntermodal3" invertProbability="100" /> </SubTrailers> </Trailer> <Trailer name="40/20 MSC Hamburg + 40/20 Maersk"> <SubTrailers> <Trailer name="869739118.TrailerClass66FreightlinerIntermodal4" /> <Trailer name="869739118.TrailerClass66FreightlinerIntermodal1" invertProbability="100" /> </SubTrailers> </Trailer> <Trailer name="40/20 MSC Hamburg + 20/0/20 Maersk"> <SubTrailers> <Trailer name="869739118.TrailerClass66FreightlinerIntermodal4" /> <Trailer name="869739118.TrailerClass66FreightlinerIntermodal2" invertProbability="100" /> </SubTrailers> </Trailer> <Trailer name="40/20 MSC Hamburg + 20/20/20 Hamburg"> <SubTrailers> <Trailer name="869739118.TrailerClass66FreightlinerIntermodal0" /> <Trailer name="869739118.TrailerClass66FreightlinerIntermodal4" invertProbability="100" /> </SubTrailers> </Trailer> <Trailer name="2x 40ft MSC"> <SubTrailers> <Trailer name="869739118.TrailerClass66FreightlinerIntermodal3" /> <Trailer name="869739118.TrailerClass66FreightlinerIntermodal3" invertProbability="100" /> </SubTrailers> </Trailer> </Trailers> </TrailerCollection> </Collections> </TrailerDefinition>
A TrailerDefinition has a name to identify it and a list of trailers. This list of trailers is the same as one inside a vehicle, so nothing new there.

To use a collection you can add a Trailer to the vehicle with the name of the collection. To indicate we are referring to a collection you set collection to true. A weight for the random selection can also be given to a collection here. The default is 10 just like with trailers.
Each Trailer that is not a collection is added to the vehicle's own, unique collection which always has a weight of 10.

When spawning a vehicle, first a collection is picked at random. Then only trailers from that collection are used for the random selection of the trailers.

Trailer count
To randomize trailer count you can add a TrailerCount tag to a vehicle like so:
<Vehicle name="NS 2200 Tanker Train" useDefault="true"> <TrailerCount min="9" max="15" /> <Trailers> <Trailer name="NS6516_NS_Falns.Trailer1" /> <Trailer name="NS6424_DB_Kls_Hout.Trailer0" /> <Trailer name="NS1616-Sahimms-8-24.Trailer0" /> </Trailers> </Vehicle>
The min and max tags are required. Min most be less than or equal to max. By setting both to the same value you can easily change the fixed trailer count of an asset.

Note: the trailer count is only randomized when the trailers are as well.

Cargoes
Cargo types for trailers can be specified with the CargoType tag like so:
<Trailer name="744317396.Trailer9"> <CargoType>Food Goods</CargoType> </Trailer>
The types are space seperated. The following cargo types can be used:
  • None
  • Oil
  • Petrol
  • Ore
  • Coal
  • Logs
  • Lumber
  • Grain
  • Food
  • Goods
  • Mail
  • Metals
  • AnimalProducts
Note: Using None will allow the trailer to be used for ALL cargo types. This is also the default when no CargoType tag is given.

Note: The mod has to convert game cargo types to mod cargo types and then also back to gate indexes / submesh variations. The asset selection is picked based on the mod cargo types listed above. The gates/variations determine what submeshes of the asset are displayed, this is used for cargo trains since the Industries patch. The most up to date conversion table can be found on https://github.com/Acc3ssViolation/RandomTrainTrailers/blob/master/Cargo%20Transfer%20Reasons.txt
Last edited by Acc3ss Violation; 2 Nov, 2018 @ 10:07am
< >
Showing 1-15 of 50 comments
MajorTom 23 Feb, 2017 @ 12:33pm 
Wow. what a wonderful mod and a wonderful tutorial. You are a fantastic member of the community!
Tim The Terrible 24 Feb, 2017 @ 6:03am 
This made me think about updating my old assets. Keeping this mod in mind I shouldn't change up the configuration of the train's car. Perhaps I should upload my updated assets as new instead of updating, that way I'm free to use whatever configuration so people don't have to edit their XML's all the time.
Sottam 26 Feb, 2017 @ 7:54pm 
is there anyway in these configs to limit how long a train is? i`m having some problems with the longest ones in my city and i`d like to limit their size! thx!
Acc3ss Violation  [developer] 27 Feb, 2017 @ 3:46am 
No, there's no way to override the train length via the config corrently. I might add something like that later.
Sottam 27 Feb, 2017 @ 3:20pm 
it would be awesome if you add an option like that, maybe keep the length random, but limited to a set rand. Unfortunately, i'll have to stop using this mod in my city for now, since this too long trains are generating deadlocks in my train systems :`(
duffy 30 Mar, 2017 @ 1:41am 
+1 for trailer limit
Armandeus 30 Jul, 2017 @ 12:17am 
Wonderful mod. Bravo. But another +1 for train length global limit please.
Acc3ss Violation  [developer] 30 Jul, 2017 @ 2:35am 
Global trailer limit added, it's in the mod options menu.
Armandeus 30 Jul, 2017 @ 4:56am 
Thank you!
Future 22 Jun, 2019 @ 2:56pm 
I don't know where i should ask, but the mod is broken for me. Once I select a locomotive, it returns me to the RTT menu, without any train and some of the buttons don't work... help
Acc3ss Violation  [developer] 23 Jun, 2019 @ 2:16am 
Once you add a new locomotive it returns you to the main mod menu yes. By default both the trailer list in the middle and the blacklist on the right are empty. There is a checkbox on the right that says "Use default trailers as well", which means that the trailer list automatically includes all trailers that are part of the train asset (even though it doesn't list them, bad UI, I know :P). If you use the add trailer button you can add any other trailer to the list and it will show up in the list. Also note that the mod won't apply any changes until you click the save button.
Future 23 Jun, 2019 @ 7:20am 
The "use default trailers as well" checkbox is missing
Acc3ss Violation  [developer] 23 Jun, 2019 @ 8:06am 
That's strange, can you post a screenshot?
Future 23 Jun, 2019 @ 3:05pm 
I put it in my Cities: Skylines > Screenshots > engine enthusiast's Screenshots page thingy on steam
Acc3ss Violation  [developer] 24 Jun, 2019 @ 2:18am 
So when you then click select it doesn't change to something like this?

https://steamuserimages-a.akamaihd.net/ugc/853850080496028574/0CF77C4DDDF7F74F53FE160E1183D3F78CAD25CC/

< >
Showing 1-15 of 50 comments
Per page: 1530 50