NML Coding : Purchase list getting out of order

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
User avatar
NekoMaster
Tycoon
Tycoon
Posts: 4001
Joined: 16 Aug 2008 22:26
Skype: neko-master
Location: Oshawa, Ontario, CANADA

NML Coding : Purchase list getting out of order

Post by NekoMaster »

I've seen this a bit with my NARS ADDON SET and now I'm seeing it with a project I'm trying to do called "2cc Wagsons in NML" that only includes the wagons/coaches from 2cc Trains in NML,
but things keep getting out of order in the Purchase lists.

Everything is proper order in the VehicleID.pnml and VehicleSort.pnml files, but in game I have things appearing at the top of the list that should be at the bottom, or things from the bottom
appearing in the middle of the purchase lists in game.

While its not game breaking its a cosmetic and gameplay issue that I would like to fix before I release anymore GRF's.

I can't be the only one that gets bothered by things being out of order.

So how would i go about fixing this?
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!
User avatar
GarryG
Tycoon
Tycoon
Posts: 5850
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML Coding : Purchase list getting out of order

Post by GarryG »

I originally had this problem when I first started to train projects,

In the 2ccts.nml file go to the bottom of the file and find

Code: Select all

//sort vehicles in purchase list
# 1 "src/vehiclesort.pnml" 1

# 9 "src/vehiclesort.pnml"
/*	This file is used to set the sort order in the vehicle purchase window.

 *	It starts with #defining the partial lists per vehicle type.

 *	These partial lists are then combined to the sort-list.

 *	This way future extensions based on parameters can easily be included.

*/
# 804 "src/vehiclesort.pnml"
sort(FEAT_TRAINS, [
Here you will find all the vehivles 2cc uses and in order Transportman wants them to be listed in purchase menu.

Cheers
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: NML Coding : Purchase list getting out of order

Post by Transportman »

Does your code include those files using an #include? Without an #include (or the actual list in your files), the sorting is not included, which can lead to random sorting.
GarryG wrote:In the 2ccts.nml file go to the bottom of the file and find
That file only exists after compiling, as it is basically an intermediate for make to pass to nmlc. But it is great to check if the file is included and what is included from that file.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
User avatar
NekoMaster
Tycoon
Tycoon
Posts: 4001
Joined: 16 Aug 2008 22:26
Skype: neko-master
Location: Oshawa, Ontario, CANADA

Re: NML Coding : Purchase list getting out of order

Post by NekoMaster »

Transportman wrote:Does your code include those files using an #include? Without an #include (or the actual list in your files), the sorting is not included, which can lead to random sorting.
When I first started this thread I guess I forgot to check that vehiclesort.pnml was included in 2ccwin.pnml.

While I did include that now, which you'll see in my picture below, the purchase list is still out of order (some of the 1st Generation wagons end up appearing before the Coaches, though its not shown in my picture)

I can provide a copy of the 2ccwin.pnml and vehiclesort.pnml if needed.

EDIT : And another screw up I could have fixed before posting this that I just found.

I forgot to add

Code: Select all

sort(FEAT_TRAINS, [
	SORTING_RBS
	SORTING_RBD
	SORTING_RBE
	SORTING_STEAM 
	SORTING_DIESEL
	SORTING_ELECTRIC
	SORTING_DMU
	SORTING_CARGODMU
	SORTING_EMU
	SORTING_SINGLE_METRO
	SORTING_METRO
	SORTING_SINGLE_MAGLEV
	SORTING_MAGLEV
	SORTING_SPECIAL
	SORTING_COACHES
	SORTING_WAGONS
]);
at the end of the vehiclesort.pnml, infact this could probably help fix my NARS Addon Set by defining sorting like this as well, though in a more NARS 2/2.5-like sorting manner
Attachments
nml_sorting_problem.png
(208.79 KiB) Not downloaded yet
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Google Adsense [Bot] and 21 guests