Altering the Capacity Text in the New Vehicle Selection Box

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

Moderator: Graphics Moderators

Post Reply
User avatar
Bob_Mackenzie
Chairman
Chairman
Posts: 823
Joined: 25 Mar 2010 13:36

Altering the Capacity Text in the New Vehicle Selection Box

Post by Bob_Mackenzie »

Dear All

Does anyone have a code snippet, or the GRFmaker way of doing it, to alter the capacity text in the new vehicle screen please?

Articulated vehicles only show the capacity of the front part by default :(

Thanks

Bob
Last edited by Bob_Mackenzie on 03 Jul 2011 22:19, edited 1 time in total.
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 991
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: Altering the Capacity Text in the New Vehicle Selection

Post by frosch »

Most likely you handle the articulated vehicle callback only in the default action3-chain, not in the purchase-list chain (cargotype 0xFF).
You might also get a red error popup in OpenTTD everytime you build an engine claiming that the NewGRF provides inconsistent information (though that only happens if the articulated parts have different refittability).
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
Bob_Mackenzie
Chairman
Chairman
Posts: 823
Joined: 25 Mar 2010 13:36

Re: Altering the Capacity Text in the New Vehicle Selection

Post by Bob_Mackenzie »

Most likely you handle the articulated vehicle callback only in the default action3-chain, not in the purchase-list chain (cargotype 0xFF).
As a user of GRFmaker that, unfortunately, didn't make a great deal of sense to me sorry


You might also get a red error popup in OpenTTD everytime you build an engine claiming that the NewGRF provides inconsistent information (though that only happens if the articulated parts have different refittability).
It happens if the refittability is the same and the front part has capacity zero

Cheers

Bob
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5631
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Altering the Capacity Text in the New Vehicle Selection

Post by PikkaBird »

Bob_Mackenzie wrote:As a user of GRFmaker that, unfortunately, didn't make a great deal of sense to me sorry
And you have discovered why no-one uses GRFmaker. It's no substitute for knowing what you're doing, especially if you're trying to do something complex.
User avatar
Bob_Mackenzie
Chairman
Chairman
Posts: 823
Joined: 25 Mar 2010 13:36

Re: Altering the Capacity Text in the New Vehicle Selection

Post by Bob_Mackenzie »

PikkaBird wrote:
Bob_Mackenzie wrote:As a user of GRFmaker that, unfortunately, didn't make a great deal of sense to me sorry
And you have discovered why no-one uses GRFmaker. It's no substitute for knowing what you're doing, especially if you're trying to do something complex.
Unfortunately I don't have the hobby time to invest in learning to code properly.

I didn't think altering one piece of text would be complex
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Altering the Capacity Text in the New Vehicle Selection

Post by FooBar »

GRFMaker is very well suited for coding properly. However, with GRFMaker you still need to understand the underlying bits completely in order to use all features. In that sense, GRFMaker is not at all easier to understand than plain NFO code. GRFMaker is some sort of GUI to NFO code, not an alternative to learning NFO (if you want an alternative to learning NFO, try NML instead).

As for the capacity: it is not some field you can tell the game what value you like to have displayed there: the value is calculated by the game. What happened now is that you provided the purchase menu with only the first part of the articulated vehicle, while you should provide it with all parts to get the complete capacity. The Dutch Tram Set suffers from the same problem currently (haven't gotten around fixing it).

Unfortunately I cannot help with GRFMaker, but hopefully now you understand why you need more than just a simple setting.
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: Altering the Capacity Text in the New Vehicle Selection

Post by DJ Nekkid »

@foorbar: I did provide you with a simple solution a year or two ago :D Quite nifty one also iirc :D
Member of the
ImageImage
User avatar
Bob_Mackenzie
Chairman
Chairman
Posts: 823
Joined: 25 Mar 2010 13:36

Re: Altering the Capacity Text in the New Vehicle Selection

Post by Bob_Mackenzie »

DJ Nekkid wrote:@foorbar: I did provide you with a simple solution a year or two ago :D Quite nifty one also iirc :D
Perhaps its simple enough for me to understand? care to share?
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Altering the Capacity Text in the New Vehicle Selection

Post by FooBar »

DJ Nekkid wrote:@foorbar: I did provide you with a simple solution a year or two ago :D Quite nifty one also iirc :D
Only 2 years ago? Wasn't that in 2008 or something?
Never gotten around actually impementing it unfortunately.

Here's the snippet you sent me back then:

Code: Select all

-1 * 0  02 01 A1 81 10 00 FF 01 \b<new capacity> 80 0F 0F  FF FF
-1 * 0  02 01 A2 81 0C 00 FF 01   A1 00 36 36   A0 00 // Lets say purchaselist sprite is A0
Currently I'm working on a new version of the dutch tram set, this time in NML. There I will be implementing a similar fix (but the other way round): I set the full capacity in the vehicle properties and then use the vehicle property callback to set a partial capacity for each part of the articulated vehicle. That has the nice side-effect that you can have more passengers in larger trailers and less passengers in smaller trailers.

Example of the callback in nml, full code in the repo:

Code: Select all

/////////////////////
//vehicle callbacks//
/////////////////////

//set number of articulated parts
switch (FEAT_ROADVEHS, SELF, switch_cbarticulated_htm_21, extra_callback_info1) {
	0..7: return tram_htm_21; //use same vehicle for all parts
	CB_FAILED;
}

//set length of each part
switch (FEAT_ROADVEHS, SELF, switch_length_htm_21, position_in_consist ) {
	0: return 0;
	1: return 1;
	2: return 2;
	3: return 3;
	4: return 4;
	5: return 5;
	6: return 6;
	7: return 7;
	CB_FAILED;
}

//set capacity of each part
switch (FEAT_ROADVEHS, SELF, switch_capacity_htm_21, position_in_consist ) {
	0: return 10;
	1: return 20;
	2: return 30;
	3: return 40;
	4: return 50;
	5: return 60;
	6: return 70;
	7: return 80;
	CB_FAILED;
}

switch (FEAT_ROADVEHS, SELF, switch_properties_htm_21, extra_callback_info1) {
    PROP_ROADVEHS_CARGO_CAPACITY: switch_capacity_htm_21;
    CB_FAILED;
}

switch (FEAT_ROADVEHS, SELF, switch_tram_htm_21, current_callback) {
	VEH_CB_ARTICULATED_PARTS: switch_cbarticulated_htm_21;
	VEH_CB_WAGON_LENGTH: switch_length_htm_21;
	VEH_CB_VEHICLE_PROPERTIES: switch_properties_htm_21;
	switch_livery_htm_21;
}
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: Altering the Capacity Text in the New Vehicle Selection

Post by DJ Nekkid »

no, not that one. The one involving checking the number of parts in the consist(var2 B4 iirc?), and then apply the purchase sprite if its less then 1, and the 'what where' var2(40/41) if not...

This way all callbacks and such are in the action3 without haveing to add them twice :D

edit:
It was like this:

Code: Select all

	
// Add P-list-sprite
-1 * 0	02 00 CID_GFX 82 41 10 FF 01	// Check number of parts in consist (with same ID)
			F0 00 00 00                 	// P-list-sprite if 0 
			A0 00		                    // Use gfx if not
Member of the
ImageImage
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Altering the Capacity Text in the New Vehicle Selection

Post by FooBar »

I don't really remember that one, but it looks to be a nice solution :)
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 12 guests