Change wagon speed limit depending on load

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Change wagon speed limit depending on load

Post by FooBar »

Past saturday I was pondering the idea of allowing empty wagons to go faster than loaded wagons. I attempted some code but that didn't work. After consulting the specs I concluded that this is not possible, because (I believe) the speed callback is only called inside a depot.

Could anyone confirm that my conclusion is indeed correct? If so, please consider this a feature request :D Thanks!
Transportman
Tycoon
Tycoon
Posts: 2792
Joined: 22 Feb 2011 18:34

Re: Change wagon speed limit depending on load

Post by Transportman »

Can't you do a switch block with the cargo_count variable?
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: Change wagon speed limit depending on load

Post by wallyweb »

Intriguing. I was thinking of this very thing about a month ago.
Something to consider ... What about a mixed cargo train where a variety of cargoes are collected and dropped depending upon the stations encountered along the route? In this example the ratio of full wagons to empty wagons changes with each and every stop. Could the speed be varied according to that ratio?
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Change wagon speed limit depending on load

Post by Eddi »

FooBar wrote:(I believe) the speed callback is only called inside a depot.
it is at least also called on changing track type, entering a bridge etc., it should be easy to add "loading/unloading" to this.
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Change wagon speed limit depending on load

Post by FooBar »

I'll try the bridge thing this weekend. Then at least I know if it does what I want should loading/unloading be added.
wallyweb wrote:What about a mixed cargo train where a variety of cargoes are collected and dropped depending upon the stations encountered along the route? In this example the ratio of full wagons to empty wagons changes with each and every stop. Could the speed be varied according to that ratio?
If the speed callback were to be called on loading/unloading, then I think you can get close to this. The variables you have to work with are the amount of cargo in a wagon/train and the capacity of a wagon/train. You could get the ratio load to capacity, but not per cargo type (at least not easily).
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 991
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: Change wagon speed limit depending on load

Post by frosch »

It works for ships, the tug boats in FISH do (or did?) that.

It does not work for trains, since they cache such stuff. In fact in causes desyncs. NUTS tried to change power depending on load or something, that's why the latest versions of NUTS desync.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13235
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: Change wagon speed limit depending on load

Post by Hyronymus »

I like the way of thinking but isn't this unrealistic? Train wagons have a maximum design speed - loaded or unloaded. If you want to pull loaded selfdischargers at maximum speed you simply need to choose the proper engine.
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Change wagon speed limit depending on load

Post by Eddi »

Hyronymus wrote:I like the way of thinking but isn't this unrealistic? Train wagons have a maximum design speed - loaded or unloaded. If you want to pull loaded selfdischargers at maximum speed you simply need to choose the proper engine.
au contraire. many wagons have two design speeds, one loaded and one empty (has to do with braking power)
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: Change wagon speed limit depending on load

Post by wallyweb »

Hyronymus is on the right track, with one small consideration. Train wagons have a maximum design safe speed - loaded or unloaded. Theoretically a train can travel at any speed given sufficient power and absence of friction with the major limiting factor being the capability of the track. Some curves can be unsafe at almost any speed. The difference between loaded and unloaded is acceleration ... the time required to attain the maximum speed provided within the power limits of the engine, the weight of the consist and the rolling resistance of the wagons. TTDP and OTTD already do a reasonable job of modeling this. Just for fun, build a very long straight track and set a maximum length train upon it. Load all the wagons to capacity. Then see how many wagons have to be replaced by engines just to get the thing to move. I did this a few years ago. There is a topic somewhere in these forums describing the experience. Quite realistic to say the least.
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Change wagon speed limit depending on load

Post by FooBar »

Eddi wrote:many wagons have two design speeds, one loaded and one empty (has to do with braking power)
That is exactly why I started this topic. While researching some wagons for the Dutch Trainset, I stumbled upon this. For instance the Falns is allowed to travel at 100 km/h when loaded (with varying load depending on track class) and 120 km/h when empty.

I thought it would be nice to have this in the set as well. Of course guarded by a parameter for if you don't want it.
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Change wagon speed limit depending on load

Post by FooBar »

As promised, these are my conclusions from a bit of testing:

The speed callback runs:
- When a train exits the depot, and
- When a train reverses.
(Speed did not change on bridges, r26189)

What I would need for my purpose is that the callback also runs, either:
- When a train starts moving, or
- When a train finishes loading/unloading.

Attached is a test NewGRF (Dutch Trainset) with the callback implemented for the "Tads Selfdischarger" wagon.

I shall also post this to flyspray as a feature request. EDIT: https://bugs.openttd.org/task/5869
Attachments
dutchtrains.tar
(2.37 MiB) Downloaded 122 times
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 17 guests