Page 7 of 14

Re: Various NML related questions

Posted: 12 Sep 2017 16:38
by Transportman
You don't close your cargotable block, so the switch directly after that is considered part of that block, where it is not possible to be.

Also, the code you propose

Code: Select all

cargo_subtype: PRAGA_N_LIVERY_SWITCH;
is not valid, there is no cargo_subtype graphics-property. If you do not want livery overrides, the default: should point to the correct switch or spriteset.

Re: Various NML related questions

Posted: 13 Sep 2017 05:16
by Greyfur
On the contrary.

My aim is to have several refits for the same cargo - that is the whole point of the switch.

When I add it to the

Code: Select all

default:
it doesnt allow any refits.

Can someone provide an advice how to create refits for the same cargo?

Two ways I tried:

1st switching through cargotable:
[+] Spoiler

Code: Select all

cargotable {
    PASS, 
    MAIL 
}
switch(FEAT_ROADVEHS, SELF, PRAGA_N_LIVERY_SWITCH, cargo_subtype) {
    0:      PRAGA_N_0;
    1:      PRAGA_N_1;
    2:      PRAGA_N_2;
    3:      PRAGA_N_3;
}

switch(FEAT_ROADVEHS, SELF, sw_PRAGA_N_CARGO_SUBTYPE_TEXT, cargo_subtype) {
    0: return string(STR_NAME_PRAGA_N_0);
    1: return string(STR_NAME_PRAGA_N_1);
    2: return string(STR_NAME_PRAGA_N_2);
    3: return string(STR_NAME_PRAGA_N_3);
    return CB_RESULT_NO_TEXT;
}
 switch(FEAT_ROADVEHS, SELF, PRAGA_N_CAPACITY_SWITCH, cargo_subtype) {
       0: 35;
       1: 40;
       2: 35;
       3: 40;

item (FEAT_ROADVEHS, ITEM_PRAGA_N) {
						property {
        						   name: string(STR_NAME_PRAGA_N);
        						   climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL);
       							   introduction_date: date(1915,01,01);
        						   model_life: 11;
        						   vehicle_life: 11;
        						   reliability_decay: 20;
                                  			   refittable_cargo_classes:    bitmask(CC_PASSENGERS);
							   cargo_allow_refit: [PASS];
							   refit_cost: 0; 
						           loading_speed: 5; 
						           cost_factor: 108;
						           running_cost_factor: 90; 
						           sprite_id: SPRITE_ID_NEW_ROADVEH;
						           speed: 40 km/h;
 						           running_cost_base: RUNNING_COST_ROADVEH;
						           power: 45 hp;
							   weight: 4.5 ton;
						           sound_effect: SOUND_BUS_START_PULL_AWAY;
						        }

					       graphics {
        						   default:  PRAGA_N_0;
							   PASS: PRAGA_N_LIVERY_SWITCH;
							   cargo_subtype_text: sw_PRAGA_N_CARGO_SUBTYPE_TEXT;
                                                           cargo_capacity: PRAGA_N_CAPACITY_SWITCH;
							   purchase_cargo_capacity: 25;
							}
					  }

2nd switching through cargo-subtype at default in graphics section:
[+] Spoiler

Code: Select all


switch(FEAT_ROADVEHS, SELF, SKODA_505_LIVERY_SWITCH, cargo_subtype) {
    0:      SKODA_505_0;
    1:      SKODA_505_1;
    2:      SKODA_505_2;
    3:      SKODA_505_3;
    4:      SKODA_505_4;
}

switch(FEAT_ROADVEHS, SELF, SWITCH_SKODA_505_CARGO_SUBTYPE_TEXT, cargo_subtype) {
    0: return string(STR_NAME_SKODA_505_0);
    1: return string(STR_NAME_SKODA_505_1);
    2: return string(STR_NAME_SKODA_505_2);
    3: return string(STR_NAME_SKODA_505_3);
    4: return string(STR_NAME_SKODA_505_4);
    return CB_RESULT_NO_TEXT;
}
switch(FEAT_ROADVEHS, SELF, SKODA_505_CAPACITY_SWITCH, cargo_subtype) {
    0: 32;
    1: 32;
    2: 32;
    3: 32;
    4: 32;
}

item (FEAT_ROADVEHS, ITEM_SKODA_505) {
						property {

        						   /* Properties common to all vehicle types */
        						   name: string(STR_NAME_SKODA_505);
        						   climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL);
       							   introduction_date: date(1923,01,01);
        						   model_life: 7;
        						   vehicle_life: 25;
        						   reliability_decay: 20;
						           loading_speed: 5; //                    STRING***********
						           cost_factor: 108; //				     **********POZRIET*********
						           running_cost_factor: 90; //				     **********POZRIET*********
						        /* cargo_age_period is left at default */
						           /* RV-specific properties */
						           sprite_id: SPRITE_ID_NEW_ROADVEH;
						           speed: 40 km/h;
							//        misc_flags: bitmask(ROADVEH_FLAG_2CC); //    **********POZRIET*********
 						           running_cost_base: RUNNING_COST_ROADVEH;
						           power: 35 hp;
							   weight: 3.6 ton;
						        /* TE and air drag coefficient is left at default */
                                   refittable_cargo_classes:    bitmask(CC_PASSENGERS);
						           

						        sound_effect: SOUND_BUS_START_PULL_AWAY;
						        }

					       graphics {
        						   default:  SKODA_505_LIVERY_SWITCH;
							   cargo_subtype_text: SWITCH_SKODA_505_CARGO_SUBTYPE_TEXT;
							   cargo_capacity: SKODA_505_CAPACITY_SWITCH;
							   purchase_cargo_capacity: 32;
							}
					  }
					  
I get NO error messages when compiling the grf, all vehicles are there and are running, but none from them has an available refit.

Do I miss anything or is there some mistake I, with my minimal experience simply do not see?

Re: Various NML related questions

Posted: 18 Sep 2017 21:55
by Gwyd
So the way I've done it in the past is

Code: Select all

spriteset(spriteset_Example_Purchase, "gfx/Example.png") {
	template_purchase(237, 488)
}

spriteset(spriteset_Example_Livery2, "gfx/Example.png") {
	template_electrostar(0, 468)
}

spriteset(spriteset_Example_Livery, "gfx/Example.png") {
	template_electrostar(0, 546)
}

spriteset(spriteset_Example_Livery3, "gfx/Example.png") {
	template_electrostar(0, 0)
}


switch(FEAT_TRAINS,SELF, sw_Example,cargo_subtype){
	0:spriteset_Example_Livery;
	1:spriteset_Example_Livery2;
	2:spriteset_Example_Livery3;
	}

switch(FEAT_TRAINS,SELF,sw_Example_cargo_subtype_text,cargo_subtype){
    0:	return string(str_Livery2);
    1:	return string(str_Livery);
    2:	return string(str_Livery3);
       return CB_RESULT_NO_TEXT;
}

item (FEAT_TRAINS, item_Example, xxx) {
	property {
		name: 							string(STR_NAME_Example);
		climates_available: 			ALL_CLIMATES;
		introduction_date:				date(1987,4,21);
		model_life:						15;
		retire_early:					1;
		vehicle_life:					50;
		reliability_decay:				7;
		refittable_cargo_classes:		0;
		cargo_allow_refit:				[PASS];
		loading_speed:					25;
		cost_factor:					61;
		running_cost_factor:			37;
		sprite_id:						SPRITE_ID_NEW_TRAIN;
		speed:							161 km/h;
		misc_flags:						TRAIN_FLAG_MU;
		refit_cost:						0;
		track_type:						BR_3RDC;
		ai_special_flag:				AI_FLAG_CARGO;
		power:							1438 hp;
		running_cost_base:				RUNNING_COST_ELECTRIC;
		dual_headed:					0;
		default_cargo_type:				PASS;
		cargo_capacity:					82;
		weight:							168 ton;
		engine_class:					ENGINE_CLASS_ELECTRIC;
		tractive_effort_coefficient:	0.03;
		air_drag_coefficient:			0.05;
		length:							8;
		effect_spawn_model_and_powered:	EFFECT_SPAWN_MODEL_ELECTRIC;
		extra_weight_per_wagon:			0;
		bitmask_vehicle_info:			0;
	}
	graphics {
	additional_text:					return(str_purchase_text);
	can_attach_wagon:					CB_RESULT_ATTACH_ALLOW;
	cargo_subtype_text:					sw_Example_cargo_subtype_text;
	articulated_part:        			switch_articulated_Example;
	default: 							sw_Example;
	purchase:							spriteset_Example_Purchase;
}
}

Re: Various NML related questions

Posted: 21 Sep 2017 19:54
by Gwyd
Just to let y'all know I updated my previous post

Re: Various NML related questions

Posted: 24 Sep 2017 14:13
by Greyfur
Thank you!

I was able to make it work. However I was not able to set any other properties of the refitted vehicle - is it possible to have cargo capacity, speed, runing costs or others changed for the refitted vehicle, when the refit is based on cargo subtype?

Re: Various NML related questions

Posted: 24 Sep 2017 18:52
by TrainLover
Can you get spritesets and liveries from different graphics files? I'm working on basically an extremely large livery set, which basically includes the liveries of the major Class I railroads of North America and I would like to use the 2cc template. I would not want to make hundreds of different purchase files for each individual railroad, I would just want someone to be able to refit for the desired livery.

Re: Various NML related questions

Posted: 25 Sep 2017 17:47
by Transportman
Greyfur wrote:Thank you!

I was able to make it work. However I was not able to set any other properties of the refitted vehicle - is it possible to have cargo capacity, speed, runing costs or others changed for the refitted vehicle, when the refit is based on cargo subtype?
I expect that will be possible, for each property you would have one switch based on the cargo_type_in_veh variable, and that switch then points to additional switches that set the value based on the cargo_subtype.

Question is, how playable that will be, if you have too many changes it might get confusing.
TrainLover wrote:Can you get spritesets and liveries from different graphics files? I'm working on basically an extremely large livery set, which basically includes the liveries of the major Class I railroads of North America and I would like to use the 2cc template. I would not want to make hundreds of different purchase files for each individual railroad, I would just want someone to be able to refit for the desired livery.
Each sprite can be in a separate file if you want to, but you can also put all sprites in 1 file, and everything in between.

Re: Various NML related questions

Posted: 25 Sep 2017 19:22
by Gwyd
Switches relating to livery are done through

Code: Select all

 switch(FEATURE, [SELF|PARENT], sw_switchname, cargo_subtype){
Not sure if it helps, but there you go

Re: Various NML related questions

Posted: 26 Sep 2017 00:40
by Greyfur
So, the property switch overrides will be located in the item graphics section after the text and graphics switches?

Re: Various NML related questions

Posted: 26 Sep 2017 00:52
by Leanden
The switch itself comes above the item block, but you then reference it in the graphics block

Re: Various NML related questions

Posted: 04 Oct 2017 12:12
by Greyfur
I seem to have a huge issue with the callbacks.

Every time I am doing a callback I receive an error.

Currently with this one:

Code: Select all

switch(FEAT_ROADVEHS, SELF, power_B731yob_switch, build_year) {
    1982..1985:   202;
	1986..1996:     211;
 }	
 
 
item (FEAT_ROADVEHS, ITEM_B731) {
						property {
...
						           power: 211 hp;		
...
}

					       graphics {
								   cargo_subtype_text: sw_B731_CARGO_SUBTYPE_TEXT;
        						           sw_B731_LIVERY_SWITCH;
								   power: power_B731yob_switch hp;
							}
					  }
The Error I am receiving:
nmlc ERROR: "CS_BusSetw05lc735.nml", line 288: Syntax error, unexpected token "power"

The same issue appears even if the "hp" is removed and if I put hp to the switch value, I get an error for that.

I got the same duplicate error with cargo_capacity, when trying to do a callback through a switch based on cargo_subtype.

Anybody having a suggestion what am I doing wrong?

Re: Various NML related questions

Posted: 04 Oct 2017 15:30
by Leanden
You dont need to put the hp at all, just a numerical value.

The units are auto imported from the item block

Re: Various NML related questions

Posted: 04 Oct 2017 15:44
by Greyfur
Ok, good to know!

Any idea on the error?

Re: Various NML related questions

Posted: 04 Oct 2017 17:10
by Alberth
Greyfur wrote:Ok, good to know!

Any idea on the error?
What does "sw_B731_LIVERY_SWITCH;" do there? I am guessing it needs a callback name prefix?

Re: Various NML related questions

Posted: 05 Oct 2017 15:05
by Transportman
Alberth wrote:
Greyfur wrote:Ok, good to know!

Any idea on the error?
What does "sw_B731_LIVERY_SWITCH;" do there? I am guessing it needs a callback name prefix?
I guess it is the default callback, so I expect that the error happens because the default callback is before the final callback. @Greyfur: Can you move the callback in the graphics-block up, so that the sw_B731_LIVERY_SWITCH is the last one?

Re: Various NML related questions

Posted: 06 Oct 2017 04:03
by Alberth
Preferably also label it as default, as in https://newgrf-specs.tt-wiki.net/wiki/N ... hics_block

The switch could also use some additional 'return' keywords for clarity, as in https://newgrf-specs.tt-wiki.net/wiki/NML:Switch

Re: Various NML related questions

Posted: 10 Oct 2017 13:31
by Greyfur
I didn't reply as adding the default: callback name did work and I was working on my code! Thank you so much!

There are two more things.

There are two subversions of a type built in the same year. I was able to create a switch that randomly gives you a subtype when buying the bus. One subtype is called C734.00, the other C734.03.

Now I would like to keep that subtype name after a livery refit. Is there a way to load the name into some variable and somehow reuse it after refit?

The other is - is there a way to add two different texts from two different switches one after another?

Re: Various NML related questions

Posted: 22 Nov 2017 10:59
by Wahazar
Currently I have 600mm gauge track with label NG60.
I want to add some kind of universal dual gauge track, to have possibility of easy autoreplace, or using same platform:

Code: Select all

  item (FEAT_RAILTYPES, NG600RAIL)
  {
    property
    {
      label: "NG6R";
      introduction_date: date(1883, 1, 1);
      name: string(STR_NG6R_NAME);
      toolbar_caption: string(STR_NG6R_TOOLBAR);
      menu_text: string(STR_NG6R_MENU);
      build_window_caption: string(STR_NG60_BUILD_CAPTION);
      autoreplace_text: string(STR_NG60_AUTOREPLACE);
      new_engine_text: string(STR_NG60_NEW_ENGINE);
      compatible_railtype_list: ["NG6R", "NG60", "NAAN", "RAIL", "ELRL"];
      powered_railtype_list: ["NG6R", "NG60", "NAAN", "RAIL"];
      speed_limit: 60 km/h;      
      acceleration_model: ACC_MODEL_RAIL;
      railtype_flags: bitmask();
    }
but neither no engines are available in the shed, nor both 600mm and normal gauge trains can't enter into dual gauge section.
Any ideas, what goes wrong?

Re: Various NML related questions

Posted: 22 Nov 2017 17:42
by Transportman
Do the other tracks also define that they are compatible with this universal track? I think that might solve the problem.

Re: Various NML related questions

Posted: 23 Nov 2017 01:06
by Wahazar
Thank you, Transportman, problem solved.