Dual-power locomotive?

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

Moderator: Graphics Moderators

Post Reply
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5658
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Dual-power locomotive?

Post by andythenorth »

So what's the most efficient strategy for making a dual-power locomotive?

E.g. 5,000hp if railtype supplies electricity, 1,250hp otherwise.

Yair, I haven't read the spec, and haven't touched railtype stuff before. I just got up, what can I say?
I thought it might be useful to others in future anyway.

By 'strategy' I also mean how to present the info in the buy menu - whether to show the higher power or lower power by default etc. :)

I'll be using nml, but my brain still thinks about cb 36 etc.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Dual-power locomotive?

Post by Rubidium »

Maybe take a look at the high speed trains in the Dutch train set? They run on non-25 kV tracks, but with significantly lower specs than when on the 25 kV track.
dandan
Route Supervisor
Route Supervisor
Posts: 414
Joined: 17 Feb 2008 23:01

Re: Dual-power locomotive?

Post by dandan »

andythenorth wrote:So what's the most efficient strategy for making a dual-power locomotive?

E.g. 5,000hp if railtype supplies electricity, 1,250hp otherwise.
The problem is that there is no vehicle variable that will tell you whether the railtype supplies electricity (= has catenary enabled). You can only query the railtype itself. This means that, for a dual-power locomotive, your railtype translation table has to know about all railtype labels for electrified track that are used by any track set you want to be compatible with.

The other potential problem is that not all vehicle properties are constantly updated. (If I remember correctly, power is always updated, but for example the maximum speed is not.)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Dual-power locomotive?

Post by planetmaker »

dandan wrote:
andythenorth wrote:So what's the most efficient strategy for making a dual-power locomotive?

E.g. 5,000hp if railtype supplies electricity, 1,250hp otherwise.
The problem is that there is no vehicle variable that will tell you whether the railtype supplies electricity (= has catenary enabled). You can only query the railtype itself. This means that, for a dual-power locomotive, your railtype translation table has to know about all railtype labels for electrified track that are used by any track set you want to be compatible with.

The other potential problem is that not all vehicle properties are constantly updated. (If I remember correctly, power is always updated, but for example the maximum speed is not.)
That may sound like a big problem. But I don't think it needs to be a real big problem. FooBar did a good treatise on railtype labels and also supplies a very decent RTT (alternatively this modified one from OpenGFX+Trains)
Eddi
Tycoon
Tycoon
Posts: 8272
Joined: 17 Jan 2007 00:14

Re: Dual-power locomotive?

Post by Eddi »

i was considering writing "comparison" functions for the newgrf specs, i.e. something like "give two railtype labels, return true if vehicles defined for the first are powered on the second" or "return true if the two railtype labels are mapped to the same railtype". the question is how to specify that and pass the parameters. maybe comparable to the grf activation checks or something. also a question to be answered is if this should be accessible through action6/7/9/D or varaction2
dandan
Route Supervisor
Route Supervisor
Posts: 414
Joined: 17 Feb 2008 23:01

Re: Dual-power locomotive?

Post by dandan »

planetmaker wrote:FooBar did a good treatise on railtype labels and also supplies a very decent RTT (alternatively this modified one from OpenGFX+Trains)
Good to know, thanks for the link.
Eddi wrote:i was considering writing "comparison" functions for the newgrf specs, i.e. something like "give two railtype labels, return true if vehicles defined for the first are powered on the second"
That would be useful and more future-proof than an extensive railtype table. On the other hand, it may be too much trouble for too little benefit. Do you have any uses in mind other than dual-power locomotives?
Eddi
Tycoon
Tycoon
Posts: 8272
Joined: 17 Jan 2007 00:14

Re: Dual-power locomotive?

Post by Eddi »

my use case would be to detect whether a set provides different axle weights (because in my set a lot of vehicles don't make sense without that)

since more and more sets use the standardized railtype scheme, simple existence of a railtype is not enough to detect this.
Eddi
Tycoon
Tycoon
Posts: 8272
Joined: 17 Jan 2007 00:14

Re: Dual-power locomotive?

Post by Eddi »

a possible way how this could look:

Action 7 condition type:
0F/10: railtype <variable> [index into RTT] is [not] equvalent to railtype label <value>
11/12: railtype <variable> is [not] compatible on railtype label <value>
13/14: railtype <variable> is [not] powered on railtype label <value>

with each condition being false if <value> is not defined (there is already a condition to check that)
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Dual-power locomotive?

Post by PikkaBird »

andythenorth wrote:By 'strategy' I also mean how to present the info in the buy menu - whether to show the higher power or lower power by default etc. :)
I'd put the higher power in the buy menu if that's the "normal" operating condition, and then a note to the effect that it can run off-grid at lower power.
I'll be using nml, but my brain still thinks about cb 36 etc.
For the Class 73 in UKRS2, I just did a simple split based on the railtype, then had two seperate chains for power, sound, effects etc, one diesel and one electric.
dandan wrote:The other potential problem is that not all vehicle properties are constantly updated. (If I remember correctly, power is always updated, but for example the maximum speed is not.)
I'm pleased to tell you that top speed is updated when changing railtype - the A-Train in UKRS2, for example, does 155mph under wires but 100mph on 3rd rail.
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: Dual-power locomotive?

Post by Transportman »

For what TS wants, defining his train as RAIL would allow it to run on both RAIL and ELRL by default, and then using a switch block like is used in the Dutch Train Set he can set the power of the vehicle depending on the railtype. But as soon as tracksets are loaded, everything can be possible, as it can change the compatible and powered railtype lists, but I'm not aware of any set that restricts the default lists.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
dandan
Route Supervisor
Route Supervisor
Posts: 414
Joined: 17 Feb 2008 23:01

Re: Dual-power locomotive?

Post by dandan »

PikkaBird wrote: I'd put the higher power in the buy menu if that's the "normal" operating condition, and then a note to the effect that it can run off-grid at lower power.
I agree. That also reflects best how such engines are normally used in real life.
I'm pleased to tell you that top speed is updated when changing railtype - the A-Train in UKRS2, for example, does 155mph under wires but 100mph on 3rd rail.
Ah, very good. I was not sure and the wiki is vague on this point. So, looking at the list of vehicle properties, everything that could sensibly depend on the railtype is updated?

@Eddi: This would probably be the best way to solve your problem. Of course, at the moment the number of tracks sets that implement axle weights is quite short (possibly empty?) but, again, to be future-proof...
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 21 guests