Page 1 of 1

[NML] Refit Menu Code not working

Posted: 30 Sep 2018 14:41
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

Re: [NML] Refit Menu Code not working

Posted: 30 Sep 2018 14:58
by Tony Pixel
Maybe You should delete

Code: Select all

calacity: 0;
from graphics block?

Re: [NML] Refit Menu Code not working

Posted: 30 Sep 2018 15:04
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;
}    

Re: [NML] Refit Menu Code not working

Posted: 30 Sep 2018 15:11
by Tony Pixel
And can You send me those older GRF item block and graphics switches?

Re: [NML] Refit Menu Code not working

Posted: 30 Sep 2018 15:13
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;
}

Re: [NML] Refit Menu Code not working

Posted: 30 Sep 2018 19:21
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

Re: [NML] Refit Menu Code not working

Posted: 30 Sep 2018 19:35
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.

Re: [NML] Refit Menu Code not working

Posted: 30 Sep 2018 21:42
by PNDA_
I've sorted it now, no need for further help, thanks

Re: [NML] Refit Menu Code not working

Posted: 01 Oct 2018 00:56
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/)

Re: [NML] Refit Menu Code not working

Posted: 01 Oct 2018 11:21
by Gwyd
The solution was he had the wrong version of the GRF loaded in the game, so the displayed data was wrong

Re: [NML] Refit Menu Code not working

Posted: 01 Oct 2018 14:39
by Eddi
ah, a classic :)