Fixed consists in NML

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

Moderator: Graphics Moderators

Post Reply
audigex
Tycoon
Tycoon
Posts: 1998
Joined: 09 Dec 2007 21:28
Contact:

Fixed consists in NML

Post by audigex »

Hi

I'm looking at implementing a couple of trains in NML, but I can't find any information on how to make fixed length consists

In an ideal world I'd have a few options

Type 1: Fixed consist (eg 3-car, nothing else)
Type 2: Fixed consist, but with a couple of options (eg 3 or 4 car, nothing else)
Type 3: Fixed consist, with multiple configurations and multiples allowed (eg 3 or 4 car, but with an ability to stack these, eg 3+3, 4+4, 3+4 etc)

As an advanced option, would it be possible to also only allow certain liveries with certain combinations

eg if I take a 3-car type 2, it has liveries One and Two, but if I take a 4-car it has liveries Two, Three and Four?

I don't necessarily need someone to write the code up for this, just an idea of where I can get some information on these kinds of techniques would be great.

Thanks
Jon
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Fixed consists in NML

Post by planetmaker »

You are looking for articulated vehicles and you want to make use mostly of the articulated_part callback. As for refit (type 2 and type3) you need to make use of the cargo_subtype_text callback - and maybe fudge a bit by hiding unused vehicles when you want to refit between different number of displayed vehicles.
Type3 could also be done by simply allowing to attach wagon(s) and displaying the vehicle however it should look for the actual length (might be the most user-friendly version for that).

I'm sure you find many code examples in existing train sets like the DutchTS, IronHorse, 2ccTS, NUTS,...

EDIT: please don't double-post the question in separate forum sections
audigex
Tycoon
Tycoon
Posts: 1998
Joined: 09 Dec 2007 21:28
Contact:

Re: Fixed consists in NML

Post by audigex »

Whoops, I thought I deleted the other post when I made this one! I realized the other was in the wrong section and went to delete it, but I must have missed a step

Thanks for the pointer, I'll take a look and see how I get on. More questions to follow, most likely
Jon
Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: Fixed consists in NML

Post by Supercheese »

The most relevant portions of the NML tutorial for you I believe will be the Three-part Articulated example and subsequent Four-part Refit. These should cover pretty much all of what you indicated you want to do.
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 3 guests