Page 1 of 1

Altering the Capacity Text in the New Vehicle Selection Box

Posted: 03 Jul 2011 09:21
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

Re: Altering the Capacity Text in the New Vehicle Selection

Posted: 03 Jul 2011 09:52
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).

Re: Altering the Capacity Text in the New Vehicle Selection

Posted: 03 Jul 2011 22:19
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

Re: Altering the Capacity Text in the New Vehicle Selection

Posted: 03 Jul 2011 23:43
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.

Re: Altering the Capacity Text in the New Vehicle Selection

Posted: 04 Jul 2011 11:11
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

Re: Altering the Capacity Text in the New Vehicle Selection

Posted: 04 Jul 2011 11:49
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.

Re: Altering the Capacity Text in the New Vehicle Selection

Posted: 07 Jul 2011 14:18
by DJ Nekkid
@foorbar: I did provide you with a simple solution a year or two ago :D Quite nifty one also iirc :D

Re: Altering the Capacity Text in the New Vehicle Selection

Posted: 07 Jul 2011 15:11
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?

Re: Altering the Capacity Text in the New Vehicle Selection

Posted: 07 Jul 2011 15:35
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;
}

Re: Altering the Capacity Text in the New Vehicle Selection

Posted: 07 Jul 2011 20:20
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

Re: Altering the Capacity Text in the New Vehicle Selection

Posted: 07 Jul 2011 21:07
by FooBar
I don't really remember that one, but it looks to be a nice solution :)