Train replacement
Moderator: Graphics Moderators
- cmoiromain
- Chief Executive
- Posts: 655
- Joined: 15 Jan 2007 21:45
- Location: FRANCE
- Contact:
Train replacement
After years of people regularly asking for ways to easily update from rail to monorail and maglev, this is finally possible. If I have understood correctly, the new rail types allow us to create a new intermediate rail type that can have both normal trains and maglev (or monorail). This would be the ideal solution, to send all trains to autorenew without having to copy hundreds of trains manually.
I have already tried my hand at newgrf coding, I never managed to get any further than replacing the sprites for one single engine. I am putting the idea forward in case someone would be willing to give it a go. I know some will tell me do do it myself, which I fully understand; I just want to make things clear: I am currently entering one of the most important moments of my studies, the competition to enter the best ingeneer school I can, and therefore I won't have anytime for leisure before the end of July. However, if nobody has created this by then, I will be giving a try at this, hopefully managing to make it work (with the help of the already-talented coders, I hope).
Also, if the idea is in fact not possible, then instead of creating an intermediate track, there could be instead an intermediate engine, that can drive on all railtypes, but very slowly, so as to make replacement still a little strategic.
Please tell me if none of the two ideas is possible, but I really hope that it is. It would fill a gap that many people have tried to step across, unsuccessfully up to today.
I have already tried my hand at newgrf coding, I never managed to get any further than replacing the sprites for one single engine. I am putting the idea forward in case someone would be willing to give it a go. I know some will tell me do do it myself, which I fully understand; I just want to make things clear: I am currently entering one of the most important moments of my studies, the competition to enter the best ingeneer school I can, and therefore I won't have anytime for leisure before the end of July. However, if nobody has created this by then, I will be giving a try at this, hopefully managing to make it work (with the help of the already-talented coders, I hope).
Also, if the idea is in fact not possible, then instead of creating an intermediate track, there could be instead an intermediate engine, that can drive on all railtypes, but very slowly, so as to make replacement still a little strategic.
Please tell me if none of the two ideas is possible, but I really hope that it is. It would fill a gap that many people have tried to step across, unsuccessfully up to today.
I am little, ugly, and nasty. How do you do?
- zero.eight
- Traffic Manager
- Posts: 128
- Joined: 15 Jun 2007 01:14
Re: Train replacement
If all trains can run on one new rail type, there would be no practical reason for having any other rail types. You would also be able to build all trains from one depot, which would again make separate rail types practically useless.cmoiromain wrote:a new intermediate rail type that can have both normal trains and maglev (or monorail).
So I tried your second idea. The attached GRF works, but it isn't pretty. I'll post some usage instructions (with images) in the next post because it isn't easy to guess how to do it properly. Here's a quick description of how it works:
Say you have a number of trains running on rail type X, but you want them to be upgraded (or downgraded) to more appropriate trains running on rail type Y. You can't do this at the moment because the default rail types are incompatible (excluding normal rail on electrified). The attached GRF adds a new rail type and a "universal engine". This engine is used to push or pull any train to a depot of the rail type to which you want to convert trains, where they are autoreplaced and separated - so for example, if I want to convert monorail trains to maglev, I attach this new engine to the front or back of the monorail train, then move it to a maglev depot. I use autoreplace to convert the monorail trains to the new maglev types (e.g. Millennium Z1 to Lev4 Chimaera), then detach the universal engine and move the maglev trains onto the new maglev tracks.
Although this works, I don't particularly like it for a number of reasons:
1. It introduces a constructable rail type that has no effective use and (currently) is graphically identical to normal rail. You can't disable a rail type and have a new engine of that rail type. For that reason, I made the track extremely expensive and limited it to 30kmh-1 (changed in v1.1).
2. It allows wagons from one rail type to be used on another. Although it may be less capacity-efficient to use normal rail wagons on maglev tracks, you could use maglev wagons on normal rail and shift more cargo than a set creator may have intended.
3. It looks ugly. I can't think of any "nice" graphics for the engine that could change this.
4. You have to add and then separate the universal engine from the train. So not a hassle-free process.
Of course, all of the above are small price to pay if you want to upgrade trains more easily. The most significant advantage is that you don't have to recreate a train's orders.
Currently the universal engine uses the default graphics for a new rail vehicle, which happens to be a steam locomotive. It will look odd having a monorail train pulled by a steam loco, but I can't think of a better way to do this (change graphics according to year?)
I have only tested with the default trains using r19495. Attaching the new engine to an articulated train will probably result in glitchyness.
Anyway, hopefully this will make upgrading trains a bit easier.
GPL v2 if anyone wants to fiddle with it.
EDIT: updated to v1.1. Set the first parameter to 1 to allow all trains to use the new rail type. This makes cmoiromain's suggestion possible (see 4th post)
EDIT2: updated to v1.2. Now works in all climates.
EDIT3: updated to v1.3. Wagons can be replaced (and built) in universal depots.
EDIT4: updated to v1.4. Get it here or on BaNaNaS.
NOTE: Only tested with rail, electrified rail, monorail and maglev. Possibly doesn't work with new rail types.
Last edited by zero.eight on 12 Sep 2010 20:49, edited 7 times in total.
OpenTTD: VAST - station tiles and objects | MICS - urban monorail graphical conversion | Universal Rail Type - easier train replacement
- zero.eight
- Traffic Manager
- Posts: 128
- Joined: 15 Jun 2007 01:14
Re: Train replacement
How to use:
If you are using version 1.3 or older, method 2 is the default behaviour, so to use method 1 you should set the parameter to 1. If you are using version 1.4 or newer, method 1 is the default behaviour, so to use method 2 you should set the parameter to 1.
In this example, I want to convert two monorail trains into maglev trains by upgrading the engine and wagon models. There are two methods:
Method 1:
(0: Activate the univEngine GRF)
1. Set the first parameter to 1.
This makes the universal track usable by all (default) trains.
2. Configure autoreplace.
Select the old engine and/or wagons (e.g. X2001 in Method 1) and set up autoreplace to replace it with the new engine/wagon.
Using groups will give greater control over replacement.
3. Connect your existing network to a universal depot. You can use the universal track to do this, but remember that it is (intentionally)* very expensive and train speed is greatly restricted. Note that two tracks of different rail types cannot be on the same tile, so the depot must be connected to the network using at least one piece of universal track. See the post below for a diagram.
4. Send old trains to the universal depot. They should be upgraded (or downgraded) to whatever you selected with autoreplace.
You can keep the trains in the depot while converting the network to a new rail type (e.g. monorail to maglev), or upgrade small pieces of the network using depots at regular intervals as in the following post. Or something else.
This method will allow you to build universal engines, but they are unnecessary.
* This is to prevent players from only using the universal rail type for entire networks.
Method 2
(0: Activate the univEngine GRF)
1: Configure autoreplace for engines and wagons. It will now be possible to select any engine/wagon from any rail type in the autoreplace window. Here, I want the X2001 (monorail) to be replaced by the Lev1 (maglev) and the monorail passenger carriage to be replaced by the maglev passenger carriage.
2. Add the universal engine to the train that you want to convert. It can be placed at the front or back of the train. This has to happen in a monorail depot because I am using monorail trains.
3. Build a depot of the rail type to which you want to convert trains. I want my monorails converted to maglevs, so I build a maglev depot. Make sure it's connected and the monorail train can get to it.
4. Order your trains to go to the new depot(s). You can do this with an explicit order (i.e. create an order to go to the depot in the order list) or tell the train to go to the nearest depot (as long as the maglev depot is the nearest, the train will go there)
5. Autoreplace will convert your trains (if you have enough money). Separate the universal engine from the converted train.
6. Connect the depot to the new track and let the trains loose.
7. Repeat as necessary.
This method will allow you to build universal track, but it is unnecessary, unless you want to waste money
If you are using version 1.3 or older, method 2 is the default behaviour, so to use method 1 you should set the parameter to 1. If you are using version 1.4 or newer, method 1 is the default behaviour, so to use method 2 you should set the parameter to 1.
In this example, I want to convert two monorail trains into maglev trains by upgrading the engine and wagon models. There are two methods:
Method 1:
(0: Activate the univEngine GRF)
1. Set the first parameter to 1.
This makes the universal track usable by all (default) trains.
2. Configure autoreplace.
Select the old engine and/or wagons (e.g. X2001 in Method 1) and set up autoreplace to replace it with the new engine/wagon.
Using groups will give greater control over replacement.
3. Connect your existing network to a universal depot. You can use the universal track to do this, but remember that it is (intentionally)* very expensive and train speed is greatly restricted. Note that two tracks of different rail types cannot be on the same tile, so the depot must be connected to the network using at least one piece of universal track. See the post below for a diagram.
4. Send old trains to the universal depot. They should be upgraded (or downgraded) to whatever you selected with autoreplace.
You can keep the trains in the depot while converting the network to a new rail type (e.g. monorail to maglev), or upgrade small pieces of the network using depots at regular intervals as in the following post. Or something else.
This method will allow you to build universal engines, but they are unnecessary.
* This is to prevent players from only using the universal rail type for entire networks.
Method 2
(0: Activate the univEngine GRF)
1: Configure autoreplace for engines and wagons. It will now be possible to select any engine/wagon from any rail type in the autoreplace window. Here, I want the X2001 (monorail) to be replaced by the Lev1 (maglev) and the monorail passenger carriage to be replaced by the maglev passenger carriage.
2. Add the universal engine to the train that you want to convert. It can be placed at the front or back of the train. This has to happen in a monorail depot because I am using monorail trains.
3. Build a depot of the rail type to which you want to convert trains. I want my monorails converted to maglevs, so I build a maglev depot. Make sure it's connected and the monorail train can get to it.
4. Order your trains to go to the new depot(s). You can do this with an explicit order (i.e. create an order to go to the depot in the order list) or tell the train to go to the nearest depot (as long as the maglev depot is the nearest, the train will go there)
5. Autoreplace will convert your trains (if you have enough money). Separate the universal engine from the converted train.
6. Connect the depot to the new track and let the trains loose.
7. Repeat as necessary.
This method will allow you to build universal track, but it is unnecessary, unless you want to waste money

Last edited by zero.eight on 12 Sep 2010 20:32, edited 3 times in total.
OpenTTD: VAST - station tiles and objects | MICS - urban monorail graphical conversion | Universal Rail Type - easier train replacement
- cmoiromain
- Chief Executive
- Posts: 655
- Joined: 15 Jan 2007 21:45
- Location: FRANCE
- Contact:
Re: Train replacement
Great! I love this, thank you very much!
However, if you can make a rail type that can have all engines on it, I don't see how that kills the concept of rail types. The idea I had in mind is to actually allow such a rail type, but as you did, make it slow and maybe very expensive. That way, you don't have to allow all wagons on all rail types. People will have two ways of upgrading their network. Either, they convert everything to this new rail type, causing all their trains to drive extremely slowly (this is the downside of using the easy way), or, they add a small piece of that new rail type and a depot to their existing network. That way, trains sent to it will upgrade, and will be able to get back on the new rail type's network, also linked to that depot.
Here is a picture showing what I mean: Black is your old rail type
Red is the universal rail type
Blue is the new rail type
That way, you can gradually convert your network from one type to another, without disturbing traffic, but with a little challenge: building alongside our already existing tracks, or convert one lane out of the several you have, and using the slow universal track for junctions. That would IMO reduce the amount of micromanagement needed, but keep things challenging if you want to keep making profit while converting.
However, if you can make a rail type that can have all engines on it, I don't see how that kills the concept of rail types. The idea I had in mind is to actually allow such a rail type, but as you did, make it slow and maybe very expensive. That way, you don't have to allow all wagons on all rail types. People will have two ways of upgrading their network. Either, they convert everything to this new rail type, causing all their trains to drive extremely slowly (this is the downside of using the easy way), or, they add a small piece of that new rail type and a depot to their existing network. That way, trains sent to it will upgrade, and will be able to get back on the new rail type's network, also linked to that depot.
Here is a picture showing what I mean: Black is your old rail type
Red is the universal rail type
Blue is the new rail type
That way, you can gradually convert your network from one type to another, without disturbing traffic, but with a little challenge: building alongside our already existing tracks, or convert one lane out of the several you have, and using the slow universal track for junctions. That would IMO reduce the amount of micromanagement needed, but keep things challenging if you want to keep making profit while converting.
I am little, ugly, and nasty. How do you do?
- zero.eight
- Traffic Manager
- Posts: 128
- Joined: 15 Jun 2007 01:14
Re: Train replacement
Seems like a better idea when you put it like that. Have at look at v1.1 above. All trains can use the intermediate rail type if the GRF parameter is set to 1. Max speed is increased to 30kmh-1, and cost is reduced to ~10*costofmaglev. Might need some adjusting though. And of course it still looks like normal rail...cmoiromain wrote:However, if you can make a rail type that can have all engines on it, I don't see how that kills the concept of rail types. The idea I had in mind is to actually allow such a rail type, but as you did, make it slow and maybe very expensive...
That way, you can gradually convert your network from one type to another, without disturbing traffic, but with a little challenge: building alongside our already existing tracks, or convert one lane out of the several you have, and using the slow universal track for junctions. That would IMO reduce the amount of micromanagement needed, but keep things challenging if you want to keep making profit while converting.
OpenTTD: VAST - station tiles and objects | MICS - urban monorail graphical conversion | Universal Rail Type - easier train replacement
- cmoiromain
- Chief Executive
- Posts: 655
- Joined: 15 Jan 2007 21:45
- Location: FRANCE
- Contact:
Re: Train replacement
You are my hero!
I'll see if I come up with an idea for graphics to use by next week end, and if I do, I'll have a go at drawing them (though I'm a pretty crappy drawer).
I'll see if I come up with an idea for graphics to use by next week end, and if I do, I'll have a go at drawing them (though I'm a pretty crappy drawer).
I am little, ugly, and nasty. How do you do?
Re: Train replacement
this might be a stupid question, but why dont you "just" set the compatability of maglev and monorail to eachother plus elrails?
Re: Train replacement
Why it is needed to manuall add "universal engine"
Maybe better:
set autoreplace: monorail loco -> universal engine and universal -> maglev loco
Maybe better:
set autoreplace: monorail loco -> universal engine and universal -> maglev loco
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
- cmoiromain
- Chief Executive
- Posts: 655
- Joined: 15 Jan 2007 21:45
- Location: FRANCE
- Contact:
Re: Train replacement
Because making maglevs able to drive on electric rails is making it too easy (in my opinion).DJ Nekkid wrote:this might be a stupid question, but why dont you "just" set the compatability of maglev and monorail to eachother plus elrails?
I am little, ugly, and nasty. How do you do?
Re: Train replacement
Great work, and interesting.
For the way I play, I only use monorail/MAGLEV for high-speed passenger on dedicated routes. Taking the passenger trains off the conventional rails frees up freight capacity. With distant-join stations, you can copy the orders of your passenger trains to the monorail/MAGLEV if they serve the exact same routes. But I can't (for myself) rationalize upgrading conventional equipment to either monorail or MAGLEV, or upgrading monorail to MAGLEV.
Now, converting the track on a dedicated ROW from electrified conventional rail to monorail or MAGLEV is something I have done. But since I don't have huge electrified networks with hundreds of trains, it's not too bad to manually make the conversion.
BTW, a steam loco running on electrified rails isn't that far-fetched. In Sweden (I think) they used 0-4-0 steam locos with electric boilers powered off the catenary for maintenance, rescuing broken-down trains, etc. Such a loco was cheap, simple to build, and didn't require the copper, etc. to build electric motors.
For the way I play, I only use monorail/MAGLEV for high-speed passenger on dedicated routes. Taking the passenger trains off the conventional rails frees up freight capacity. With distant-join stations, you can copy the orders of your passenger trains to the monorail/MAGLEV if they serve the exact same routes. But I can't (for myself) rationalize upgrading conventional equipment to either monorail or MAGLEV, or upgrading monorail to MAGLEV.
Now, converting the track on a dedicated ROW from electrified conventional rail to monorail or MAGLEV is something I have done. But since I don't have huge electrified networks with hundreds of trains, it's not too bad to manually make the conversion.
BTW, a steam loco running on electrified rails isn't that far-fetched. In Sweden (I think) they used 0-4-0 steam locos with electric boilers powered off the catenary for maintenance, rescuing broken-down trains, etc. Such a loco was cheap, simple to build, and didn't require the copper, etc. to build electric motors.
Who is John Galt?
Re: Train replacement
I do like this idea because it does require some expense and effort to upgrade while solving the order problem. Won't creating a universal depot (if possible) be a better idea? Pick replacements, send to depot, upgrade track, start trains. If this seems to remove the 'challenge' increase the price of the depot to more represent a manufacturing facility rather then a repair facility (maybe use special factory graphics) or allow one one on the map at a time.
- zero.eight
- Traffic Manager
- Posts: 128
- Joined: 15 Jun 2007 01:14
Re: Train replacement
Assuming that a new rail type is not added, all trains would be able to run on all tracks, which defeats the purpose of having separate tracks. Unless the player chose to use the feature "properly"... If a new rail type were added, you could use the push/pull concept by attaching a universal engine to trains and moving them to a depot for replacement, which is the current default behaviour.DJ Nekkid wrote:this might be a stupid question, but why dont you "just" set the compatability of maglev and monorail to eachother plus elrails?
I didn't consider this. Turns out that it's a much faster method than what I had in mind, especially if you group your trains well.Kogut wrote:Why it is needed to manuall add "universal engine"
Maybe better:
set autoreplace: monorail loco -> universal engine and universal -> maglev loco
I don't upgrade networks either, mainly because I prefer sets that have higher costs for maglev (2cc Chimaera), which makes maglev profitable only with long trains and/or long distances.ostlandr wrote:Now, converting the track on a dedicated ROW from electrified conventional rail to monorail or MAGLEV is something I have done. But since I don't have huge electrified networks with hundreds of trains, it's not too bad to manually make the conversion.
The challenge is to design an engine that runs on maglev or monorail or normal track as necessaryostlandr wrote: BTW, a steam loco running on electrified rails isn't that far-fetched. In Sweden (I think) they used 0-4-0 steam locos with electric boilers powered off the catenary for maintenance, rescuing broken-down trains, etc. Such a loco was cheap, simple to build, and didn't require the copper, etc. to build electric motors.

Yep, this method is a lot faster. It is currently the secondary behaviour - you need to set the parameter to 1 to enable it. I'm not sure how depot construction cost works for new rail types, so there's something to look into. I don't think it's possible to limit the player to constructing only one. But new graphics would be useful, at the very least for the sake of differentiating the universal track from normal.YukonRob wrote:I do like this idea because it does require some expense and effort to upgrade while solving the order problem. Won't creating a universal depot (if possible) be a better idea? Pick replacements, send to depot, upgrade track, start trains. If this seems to remove the 'challenge' increase the price of the depot to more represent a manufacturing facility rather then a repair facility (maybe use special factory graphics) or allow one one on the map at a time.
OpenTTD: VAST - station tiles and objects | MICS - urban monorail graphical conversion | Universal Rail Type - easier train replacement
- zero.eight
- Traffic Manager
- Posts: 128
- Joined: 15 Jun 2007 01:14
Re: Train replacement
Now works in all climates. Should have spotted the mistake sooner
See second post.

OpenTTD: VAST - station tiles and objects | MICS - urban monorail graphical conversion | Universal Rail Type - easier train replacement
Re: Train replacement
I noticed some strange behaviour with this universal railtype:
Universal depots don't allow you to build wagons (it works fine with normal engines, though). This in turn prevents cloning whole trains and replacing wagons.
The other problem is much worse: universal rail completly disregards path reservation (i.e. PBS lets the train in, but it doesn't reserve path), which ultimately leads to crashes. Even if you avoid normal tracks, it still causes problems with trains entering universal depots.
At first, I thought it could be problem within OpenTTD, but other NewGRFs which use railtypes work just fine (NuTracks, Swedish Rails).
Universal depots don't allow you to build wagons (it works fine with normal engines, though). This in turn prevents cloning whole trains and replacing wagons.
The other problem is much worse: universal rail completly disregards path reservation (i.e. PBS lets the train in, but it doesn't reserve path), which ultimately leads to crashes. Even if you avoid normal tracks, it still causes problems with trains entering universal depots.
At first, I thought it could be problem within OpenTTD, but other NewGRFs which use railtypes work just fine (NuTracks, Swedish Rails).
- zero.eight
- Traffic Manager
- Posts: 128
- Joined: 15 Jun 2007 01:14
Re: Train replacement
Fixed in v1.3. Compatible rail types were not set correctly.Vitus wrote:I noticed some strange behaviour with this universal railtype:
Universal depots don't allow you to build wagons (it works fine with normal engines, though). This in turn prevents cloning whole trains and replacing wagons.
I cannot replicate this. Could you provide a saved game where crashes occur?Vitus wrote: The other problem is much worse: universal rail completly disregards path reservation (i.e. PBS lets the train in, but it doesn't reserve path), which ultimately leads to crashes. Even if you avoid normal tracks, it still causes problems with trains entering universal depots.
At first, I thought it could be problem within OpenTTD, but other NewGRFs which use railtypes work just fine (NuTracks, Swedish Rails).
OpenTTD: VAST - station tiles and objects | MICS - urban monorail graphical conversion | Universal Rail Type - easier train replacement
Re: Train replacement
PBS work correctly with the latest version of your NewGRF, I don't think it's needed (just for the record, I meant train crashes; just to avoid confusion).zero.eight wrote:I cannot replicate this. Could you provide a saved game where crashes occur?
Thank you.
-
- Engineer
- Posts: 14
- Joined: 10 Dec 2009 12:26
Re: Train replacement
I cant find the first prameter.zero.eight wrote:Set the first parameter to 1 to allow all trains to use the new rail type. This makes cmoiromain's suggestion possible (see 4th post)
found it silly me.
Re: Train replacement
Hello train coordinators 
I would like to give you a sample how vehicles replacement takes place in hard truck tycoon game. I found it very easy. In this game in order for the truck to start moving, you need 3 things: buy truck, hire driver and assign route. The route is a list of nodes, where truck can load or unload goods or materials. Even if there is no truck serving on this route, the route will be still listed in a Route-List table. In such way you can replace trucks without much effort

I would like to give you a sample how vehicles replacement takes place in hard truck tycoon game. I found it very easy. In this game in order for the truck to start moving, you need 3 things: buy truck, hire driver and assign route. The route is a list of nodes, where truck can load or unload goods or materials. Even if there is no truck serving on this route, the route will be still listed in a Route-List table. In such way you can replace trucks without much effort

- Attachments
-
- routes-list-table-marked.jpg (68.39 KiB) Viewed 2777 times
-
- transport-table-marked.jpg (96.09 KiB) Viewed 2777 times
Re: Train replacement
Thanks you so much for the script, but I found a bug/flaw.
I like to play with AI's, but I found out that (at least one) AI (AdmiralAI) always build with the universal track type.
Can you do something about this, or is it something de developer of the AI has to take care of?
I like to play with AI's, but I found out that (at least one) AI (AdmiralAI) always build with the universal track type.
Can you do something about this, or is it something de developer of the AI has to take care of?
- zero.eight
- Traffic Manager
- Posts: 128
- Joined: 15 Jun 2007 01:14
Re: Train replacement
Hi there. Sorry for the late response. There are two issues here:HoaD wrote:Thanks you so much for the script, but I found a bug/flaw.
I like to play with AI's, but I found out that (at least one) AI (AdmiralAI) always build with the universal track type.
Can you do something about this, or is it something de developer of the AI has to take care of?
1) AIs building the Universal Engine
2) AIs building Universal Rail track
I assume that neither case is wanted. AFAIK it isn't possible to deny construction of a vehicle or railtype to an AI while allowing a player to build them (at least not from a Railtypes perspective), although a suitable workaround might be to make the construction costs prohibitively high.
To solve #1 I can prevent construction of the Universal Engine when the NewGRF's default behaviour is used. It doesn't serve any purpose in that case anyway. I can also increase construction cost and running costs to make the engine much less attractive to AIs for when the alternative behaviour is used.
Unfortunately I can't replicate the second case. Can you provide some steps to produce a situation where an AI builds Universal Rail track?
OpenTTD: VAST - station tiles and objects | MICS - urban monorail graphical conversion | Universal Rail Type - easier train replacement
Who is online
Users browsing this forum: No registered users and 7 guests