[NML] Refit Menu Code not working

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

Moderator: Graphics Moderators

Post Reply
User avatar
PNDA_
Engineer
Engineer
Posts: 62
Joined: 18 Jul 2018 17:26
Location: Germany

[NML] Refit Menu Code not working

Post by PNDA_ »

Hey,
I already had a post a few days ago, about adding Umlaute, and ive just come across a new Problem. In my older Traxx Set, I managed to get Liveries refittable, and due to me wanting to do the same in this new Set, I used the same code, though now, I cannot refit any vehicle.

Code: Select all

switch (FEAT_TRAINS, SELF, switch_ITEM_refit, cargo_subtype) {
	0: return string(STR_ITEM_LIVERY_1);
	1: return string(STR_ITEM_LIVERY_2);
	2: return string(STR_ITEM_LIVERY_3);
	3: return string(STR_ITEM_LIVERY_4);
	4: return string(STR_ITEM_LIVERY_5);
	return CB_RESULT_NO_TEXT;
}

switch (FEAT_TRAINS, SELF, switch_ITEM, cargo_subtype) {
	0: set_ITEM_default;
	1: set_ITEM_default_2;
	2: set_ITEM_default_3;
	3: set_ITEM_default_4;
	4: set_ITEM_default_5;
}
I have all of these strings in my english.lng file and ive got all these spritesets defined above these switches.

My graphics block looks like this:

Code: Select all

graphics {
		default: switch_ITEM;
		purchase: switch_ITEM_purchase;
		power: switch_ITEM_power;
		cargo_subtype_text: switch_ITEM_refit;
		additional_text: string(STR_ITEM_ADD);
		cargo_capacity: 0;
	}
nmlc does detect, if any of these switches are not referenced or not defined.

For compiling im using nml_patcher for pnml and nmlc (also used in RUKTS for example). All of these files are now encoded in UTF-8.

Thanks for any help
Last edited by PNDA_ on 28 Oct 2018 19:41, edited 1 time in total.
Hello!
ImageImageImage
Tony Pixel
Route Supervisor
Route Supervisor
Posts: 459
Joined: 14 Oct 2017 11:06
Location: Ukraine

Re: [NML] Refit Menu Code not working

Post by Tony Pixel »

Maybe You should delete

Code: Select all

calacity: 0;
from graphics block?
Image Image
Sprite artist and NewGRF developer, coding in NML. My projects:
NewGRFs: Not Enough Subways Set | North American Passenger Railroads | Elevated Subway Bridge | Tony Pixel's Subway Equipment Set (frozen)
Screenshots: New York City Subway Episodes
User avatar
PNDA_
Engineer
Engineer
Posts: 62
Joined: 18 Jul 2018 17:26
Location: Germany

Re: [NML] Refit Menu Code not working

Post by PNDA_ »

In my older Traxx GRF I've got the trains to be refittable, by using this graphics block:

Code: Select all

graphics {
default:			switch_traxx_f140_ac1;
additional_text:		string(STR_ADD_TRAXX_F140_AC1);
cargo_subtype_text:	switch_refit_text_traxx_f140_ac1;
cargo_capacity: 	0;
purchase:			spriteset_purchase_traxx_f140_ac1;
}    
Tony Pixel
Route Supervisor
Route Supervisor
Posts: 459
Joined: 14 Oct 2017 11:06
Location: Ukraine

Re: [NML] Refit Menu Code not working

Post by Tony Pixel »

And can You send me those older GRF item block and graphics switches?
Image Image
Sprite artist and NewGRF developer, coding in NML. My projects:
NewGRFs: Not Enough Subways Set | North American Passenger Railroads | Elevated Subway Bridge | Tony Pixel's Subway Equipment Set (frozen)
Screenshots: New York City Subway Episodes
User avatar
PNDA_
Engineer
Engineer
Posts: 62
Joined: 18 Jul 2018 17:26
Location: Germany

Re: [NML] Refit Menu Code not working

Post by PNDA_ »

These are my old Traxx Graphics Switches, with a parameter. These work fine, absolutly no problems

Code: Select all

switch(FEAT_TRAINS, SELF, switch_refit_text_traxx_f140_ac1, cargo_subtype){
    0: return string(STR_LIVERY_TRAXX_F140_AC1_1);
    1: return string(STR_LIVERY_TRAXX_F140_AC1_2);
	2: return string(STR_LIVERY_TRAXX_F140_AC1_3);
    return CB_RESULT_NO_TEXT;
}

switch(FEAT_TRAINS, SELF, default_switch_traxx_f140_ac1, cargo_subtype){
    0: set_traxx_f140_ac1_1;
    1: set_traxx_f140_ac1_2;
	2: set_traxx_f140_ac1_3;
}

random_switch(FEAT_TRAINS, SELF, random_switch_traxx_f140_ac1) {
	33: set_traxx_f140_ac1_1;
	33: set_traxx_f140_ac1_2;
	33: set_traxx_f140_ac1_3;
}

switch (FEAT_TRAINS, SELF, switch_traxx_f140_ac1, param_livery_selection) {
	0: default_switch_traxx_f140_ac1;
	1: random_switch_traxx_f140_ac1;
}
Hello!
ImageImageImage
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: [NML] Refit Menu Code not working

Post by Eddi »

you should have the "capacity callback" return 0, but the "capacity property" must be set to something other than 0, otherwise, refitting is disabled completely
User avatar
PNDA_
Engineer
Engineer
Posts: 62
Joined: 18 Jul 2018 17:26
Location: Germany

Re: [NML] Refit Menu Code not working

Post by PNDA_ »

Eddi wrote:you should have the "capacity callback" return 0, but the "capacity property" must be set to something other than 0, otherwise, refitting is disabled completely
If capacity callback is "cargo capacity: 0;" in the graphics block and capacity property is "cargo_capacity: 1;" in the properties block, it doesn't change anything, it still does not work. In my old Sets leaving both at 0 worked aswell.
User avatar
PNDA_
Engineer
Engineer
Posts: 62
Joined: 18 Jul 2018 17:26
Location: Germany

Re: [NML] Refit Menu Code not working

Post by PNDA_ »

I've sorted it now, no need for further help, thanks
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: [NML] Refit Menu Code not working

Post by Eddi »

it is good custom to actually tell what was wrong instead of just saying "it's solved", because someone might have a similar problem in the future and find this thread, then scream at the world "why didn't you post the solution?!?"

(see also: https://xkcd.com/979/)
User avatar
Gwyd
Chief Executive
Chief Executive
Posts: 721
Joined: 17 Apr 2017 16:52
Location: Western Ile-de-France Region

Re: [NML] Refit Menu Code not working

Post by Gwyd »

The solution was he had the wrong version of the GRF loaded in the game, so the displayed data was wrong
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: [NML] Refit Menu Code not working

Post by Eddi »

ah, a classic :)
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 23 guests