Changing livery depending on cargo

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
User avatar
FulliAutomatix
Engineer
Engineer
Posts: 119
Joined: 24 Aug 2014 12:20
Location: Kaon Prison, Cybertron

Changing livery depending on cargo

Post by FulliAutomatix »

So I've tried to use many methods of making a loco change it's livery depending on what cargo it is hauling.
Everything either works but is random and flawed or doesn't work at all.

So I've got a 37 in Regional railways and I want that to be the livery when hauling passenger
Then if it's not passenger then I want it to use one of the the Railfreight sector liveries, and that I want dependent on what cargo is hauled too because there are 6 sectors.

Anyone please explain how to do this as the NML documentation explains **** all to me?

Some code I've got going that doesn't work
[+] Spoiler

Code: Select all

template template_ee3(x,y){
	[x+0,y,8,23,-3,-11] //North
	[x+10,y,20,16,-14,-8] //North East
	[x+32,y,33,13,-17,-9] //East
	[x+67,y,20,16,-5,-8] //South East
	[x+89,y,8,23,-3,-11] //South
	[x+99,y,20,16,-14,-8] //South West
	[x+121,y,33,13,-17,-9] //West
	[x+156,y,20,16,-5,-8] //North West
}

template template_ee3_reverse(x,y){
	[x+89,y,8,23,-3,-11] //South
	[x+99,y,20,16,-14,-8] //South West
	[x+121,y,33,13,-17,-9] //West
	[x+156,y,20,16,-5,-8] //North West
	[x+0,y,8,23,-3,-11] //North
	[x+10,y,20,16,-14,-8] //North East
	[x+32,y,33,13,-17,-9] //East
	[x+67,y,20,16,-5,-8] //South East
}

template template_ee3_dirt(x,y, filename){
	[x+0,y,16,46,-6,-22, filename] //North
	[x+20,y,40,32,-28,-16, filename] //North East
	[x+64,y,66,26,-34,-18, filename] //East
	[x+134,y,40,32,-10,-16, filename] //South East
	[x+178,y,16,46,-6,-22, filename] //South
	[x+198,y,40,32,-28,-16, filename] //South West
	[x+242,y,66,26,-34,-18, filename] //West
	[x+312,y,40,32,-10,-16, filename] //North West
}

template template_ee3_dirt_reverse(x,y, filename){
	[x+178,y,16,46,-6,-22, filename] //South
	[x+198,y,40,32,-28,-16, filename] //South West
	[x+242,y,66,26,-34,-18, filename] //West
	[x+312,y,40,32,-10,-16, filename] //North West
	[x+0,y,16,46,-6,-22, filename] //North
	[x+20,y,40,32,-28,-16, filename] //North East
	[x+64,y,66,26,-34,-18, filename] //East
	[x+134,y,40,32,-10,-16, filename] //South East
}


spriteset(gfx_ee3_regional                  , "gfx/class_37.png"){template_ee3(0,75)}
spriteset(gfx_ee3_regional_reverse          , "gfx/class_37.png"){template_ee3_reverse(0,75)}
spriteset(gfx_ee3_purchase                  , "gfx/class_37.png"){template_purchase_short(178,75)}
spriteset(gfx_ee3_railfreight               , "gfx/class_37.png"){template_ee3(0,100)}
spriteset(gfx_ee3_railfreight_reverse       , "gfx/class_37.png"){template_ee3_reverse(0,100)}
spriteset(gfx_ee3_railfreight_black       	, "gfx/class_37.png"){template_ee3(235,100)}
spriteset(gfx_ee3_railfreight_black_reverse	, "gfx/class_37.png"){template_ee3_reverse(235,100)}
spriteset(gfx_ee3_railfreight_blue          , "gfx/class_37.png"){template_ee3(413,100)}
spriteset(gfx_ee3_railfreight_blue_reverse  , "gfx/class_37.png"){template_ee3_reverse(413,100)}

spriteset(gfx_ee3_dirt_light                , "gfx/class_37_dirt.png"){base_32bpp()}
spriteset(gfx_ee3_dirt_light_reverse        , "gfx/class_37_dirt.png"){base_32bpp()}
spriteset(gfx_ee3_dirt_dark                 , "gfx/class_37_dirt.png"){base_32bpp()}
spriteset(gfx_ee3_dirt_dark_reverse         , "gfx/class_37_dirt.png"){base_32bpp()}

alternative_sprites(gfx_ee3_dirt_light                , ZOOM_LEVEL_IN_2X, BIT_DEPTH_32BPP, "gfx/class_37_dirt.png"){template_ee3_dirt(0,0,"gfx/class_37_dirt.png")}
alternative_sprites(gfx_ee3_dirt_light_reverse        , ZOOM_LEVEL_IN_2X, BIT_DEPTH_32BPP, "gfx/class_37_dirt.png"){template_ee3_dirt_reverse(0,0,"gfx/class_37_dirt.png")}
alternative_sprites(gfx_ee3_dirt_dark                 , ZOOM_LEVEL_IN_2X, BIT_DEPTH_32BPP, "gfx/class_37_dirt.png"){template_ee3_dirt(0,48,"gfx/class_37_dirt.png")}
alternative_sprites(gfx_ee3_dirt_dark_reverse         , ZOOM_LEVEL_IN_2X, BIT_DEPTH_32BPP, "gfx/class_37_dirt.png"){template_ee3_dirt_reverse(0,48,"gfx/class_37_dirt.png")}


switch(FEAT_TRAINS, PARENT, sw_ee3_regional_reverse_check         , vehicle_is_reversed){ 1 : gfx_ee3_regional_reverse ; gfx_ee3_regional ; }
switch(FEAT_TRAINS, PARENT, sw_ee3_railfreight_reverse_check      , vehicle_is_reversed){ 1 : gfx_ee3_railfreight_reverse ; gfx_ee3_railfreight ; }
switch(FEAT_TRAINS, PARENT, sw_ee3_railfreight_black_reverse_check  , vehicle_is_reversed){ 1 : gfx_ee3_railfreight_black_reverse ; gfx_ee3_railfreight_black ; }
switch(FEAT_TRAINS, PARENT, sw_ee3_railfreight_blue_reverse_check   , vehicle_is_reversed){ 1 : gfx_ee3_railfreight_blue_reverse ; gfx_ee3_railfreight_blue ; }
switch(FEAT_TRAINS, PARENT, sw_ee3_dirt_light_reverse_check , vehicle_is_reversed){ 1 : gfx_ee3_dirt_light_reverse ; gfx_ee3_dirt_light ; }
switch(FEAT_TRAINS, PARENT, sw_ee3_dirt_dark_reverse_check  , vehicle_is_reversed){ 1 : gfx_ee3_dirt_dark_reverse  ; gfx_ee3_dirt_dark  ; }



switch(FEAT_TRAINS, SELF, sw_ee3_gfx_decider, cargo_classes_in_consist){
	CC_PASSENGERS : sw_ee3_regional_reverse_check ;
	sw_ee3_railfreight_reverse_check ;
}


switch(FEAT_TRAINS, SELF, sw_ee3_colours, cargo_classes_in_consist){
	CC_PASSENGERS : palette_2cc(COLOUR_DARK_BLUE, COLOUR_BLUE) ;
	palette_2cc(COLOUR_WHITE, COLOUR_GREY) ;
}

switch(FEAT_TRAINS, SELF, sw_ee3_dirt_decider, cargo_subtype){
	0 : sw_ee3_dirt_dark_reverse_check ;
}

switch(FEAT_TRAINS, SELF, sw_ee3_spritestack, [STORE_TEMP((getbits(extra_callback_info1, 8, 8) < 2 ? CB_FLAG_MORE_SPRITES : 0) | PALETTE_USE_DEFAULT, 0x100), getbits(extra_callback_info1, 8, 8)]){
	0 : sw_ee3_gfx_decider ;
	1 : sw_ee3_dirt_decider ;
}

switch(FEAT_TRAINS, SELF, sw_ee3_refit_text, cargo_subtype){
	0 : string(STR_DIRT) ;
	1 : string(STR_NO_DIRT) ;
	CB_RESULT_NO_TEXT ;
}

item (FEAT_TRAINS, item_eetype3){
	property{
		name                           : string(STR_CL68_NAME) ;  
		climates_available             : ALL_CLIMATES ;
		introduction_date              : date(1959,12,2) ;
		refit_cost                     : 0 ;
		refittable_cargo_classes       : 0 ;
		cargo_allow_refit              : [GOOD] ;
		cargo_capacity                 : 1 ;
		model_life                     : 30 ;
		vehicle_life                   : 50 ;
		reliability_decay              : 10 ;
		cost_factor                    : 55 ;
		running_cost_base              : RUNNING_COST_DIESEL ;
		running_cost_factor            : 170 ;
		speed                          : 80 mph ;
		track_type                     : RAIL ;
		power                          : 1750 hp ;
		weight                         : 100 ton ;
		engine_class                   : ENGINE_CLASS_DIESEL ;
		tractive_effort_coefficient    : 0.245 ;
		air_drag_coefficient           : 0.1 ;
		length                         : 8 ;
		misc_flags                     : bitmask(TRAIN_FLAG_SPRITE_STACK, TRAIN_FLAG_2CC) ;
		effect_spawn_model_and_powered : EFFECT_SPAWN_MODEL_DIESEL ;
		sprite_id                      : SPRITE_ID_NEW_TRAIN ;
		dual_headed                    : 0 ;
	}
	graphics{
		default                 : sw_ee3_spritestack ;
		colour_mapping          : sw_ee3_colours ;
		purchase_colour_mapping : palette_2cc(COLOUR_DARK_BLUE, COLOUR_BLUE) ;
		cargo_subtype_text      : sw_ee3_refit_text ;
		purchase                : gfx_ee3_purchase ;
		sound_effect            : sw_40_sfx ;
		create_effect           : vfx_diesel_default ;
		purchase_cargo_capacity : 0 ;
		cargo_capacity          : return 0 ;
	}
}
Oh also if someone could give me a variable I can use for either the length of time since the vehicles last service or age that would be great as well
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5658
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Changing livery depending on cargo

Post by andythenorth »

I've just done this in Iron Horse for mail cars. My code is in the spoiler below.

However before you read all that...you might want a new version of nml :D
http://dev.openttdcoop.org/projects/nml ... 8e468b64dd

Bug was described here http://dev.openttdcoop.org/issues/8548
[+] Spoiler
// default spriteset templates
template spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_unflipped(y) {
//[left_x, upper_y, width, height, offset_x, offset_y]
[180, y, 8, 29, -3, -26 ]
[193, y, 26, 24, -6, -20 ]
[224, y, 33, 16, 0, -12 ]
[263, y, 26, 24, 0, -16 ]
[180, y, 8, 29, -3, -18 ]
[193, y, 26, 24, -14, -16 ]
[224, y, 33, 16, -16, -12 ]
[263, y, 26, 24, -8, -20 ]
}
template spriteset_template_symmetric_reversed_mail_car_pony_gen_1A_unflipped(y) {
//[left_x, upper_y, width, height, offset_x, offset_y]
[180, y, 8, 29, -3, -26 ]
[193, y, 26, 24, -6, -20 ]
[224, y, 33, 16, 0, -12 ]
[263, y, 26, 24, 0, -16 ]
[180, y, 8, 29, -3, -18 ]
[193, y, 26, 24, -14, -16 ]
[224, y, 33, 16, -16, -12 ]
[263, y, 26, 24, -8, -20 ]
}
template spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_flipped(y) {
//[left_x, upper_y, width, height, offset_x, offset_y]
[180, y, 8, 29, -3, -18 ]
[193, y, 26, 24, -14, -16 ]
[224, y, 33, 16, -16, -12 ]
[263, y, 26, 24, -8, -20 ]
[180, y, 8, 29, -3, -26 ]
[193, y, 26, 24, -6, -20 ]
[224, y, 33, 16, 0, -12 ]
[263, y, 26, 24, 0, -16 ]
}
template spriteset_template_symmetric_reversed_mail_car_pony_gen_1A_flipped(y) {
//[left_x, upper_y, width, height, offset_x, offset_y]
[180, y, 8, 29, -3, -18 ]
[193, y, 26, 24, -14, -16 ]
[224, y, 33, 16, -16, -12 ]
[263, y, 26, 24, -8, -20 ]
[180, y, 8, 29, -3, -26 ]
[193, y, 26, 24, -6, -20 ]
[224, y, 33, 16, 0, -12 ]
[263, y, 26, 24, 0, -16 ]
}
// buy menu spriteset template
template spriteset_template_purchase_mail_car_pony_gen_1A(y) {
//[left_x, upper_y, width, height, offset_x, offset_y]
[60, 10, 1, 1, 0, 0]
[60, 10, 1, 1, 0, 0]
[107, 10, 1, 1, 0, 0]
[60, 10, 1, 1, 0, 0]
[60, 10, 1, 1, 0, 0]
[60, 10, 1, 1, 0, 0]
// allow for buffers/couplings being 1px additional to the unit (they overlap in consists, but show in buy menu)
[224, y, 17, 16, -8, -11 ]
[60, 10, 1, 1, 0, 0]
}
// default graphics chain
spriteset(mail_car_pony_gen_1A_ss_doors_closed_livery_1_0_unflipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_unflipped(10 + 0)
}
spriteset(mail_car_pony_gen_1A_ss_doors_open_livery_1_0_unflipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_unflipped(10 + 0 + 30)
}
spriteset(mail_car_pony_gen_1A_ss_doors_closed_livery_2_0_unflipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_unflipped(10 + 0 + 60)
}
spriteset(mail_car_pony_gen_1A_ss_doors_open_livery_2_0_unflipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_unflipped(10 + 0 + 90)
}
spritegroup mail_car_pony_gen_1A_sg_livery_1_0_unflipped {
loaded: [
mail_car_pony_gen_1A_ss_doors_closed_livery_1_0_unflipped,
];
loading: [
mail_car_pony_gen_1A_ss_doors_open_livery_1_0_unflipped,
];
}
spritegroup mail_car_pony_gen_1A_sg_livery_2_0_unflipped {
loaded: [
mail_car_pony_gen_1A_ss_doors_closed_livery_2_0_unflipped,
];
loading: [
mail_car_pony_gen_1A_ss_doors_open_livery_2_0_unflipped,
];
}
spriteset(mail_car_pony_gen_1A_ss_doors_closed_livery_1_0_flipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_flipped(10 + 0)
}
spriteset(mail_car_pony_gen_1A_ss_doors_open_livery_1_0_flipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_flipped(10 + 0 + 30)
}
spriteset(mail_car_pony_gen_1A_ss_doors_closed_livery_2_0_flipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_flipped(10 + 0 + 60)
}
spriteset(mail_car_pony_gen_1A_ss_doors_open_livery_2_0_flipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_flipped(10 + 0 + 90)
}
spritegroup mail_car_pony_gen_1A_sg_livery_1_0_flipped {
loaded: [
mail_car_pony_gen_1A_ss_doors_closed_livery_1_0_flipped,
];
loading: [
mail_car_pony_gen_1A_ss_doors_open_livery_1_0_flipped,
];
}
spritegroup mail_car_pony_gen_1A_sg_livery_2_0_flipped {
loaded: [
mail_car_pony_gen_1A_ss_doors_closed_livery_2_0_flipped,
];
loading: [
mail_car_pony_gen_1A_ss_doors_open_livery_2_0_flipped,
];
}
// handle user flipped state
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_livery_1_0, vehicle_is_flipped) {
1: return mail_car_pony_gen_1A_sg_livery_2_0_flipped;
return mail_car_pony_gen_1A_sg_livery_1_0_unflipped;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_livery_2_0, vehicle_is_flipped) {
1: return mail_car_pony_gen_1A_sg_livery_1_0_flipped;
return mail_car_pony_gen_1A_sg_livery_2_0_unflipped;
}
switch (FEAT_TRAINS, PARENT, mail_car_pony_gen_1A_switch_graphics_engine_id_0, vehicle_type_id) {
standard: return mail_car_pony_gen_1A_switch_graphics_livery_2_0;
high_flyer: return mail_car_pony_gen_1A_switch_graphics_livery_2_0;
raven: return mail_car_pony_gen_1A_switch_graphics_livery_2_0;
northcock: return mail_car_pony_gen_1A_switch_graphics_livery_2_0;
electra: return mail_car_pony_gen_1A_switch_graphics_livery_2_0;
wizzo: return mail_car_pony_gen_1A_switch_graphics_livery_2_0;
roarer: return mail_car_pony_gen_1A_switch_graphics_livery_2_0;
thunderbird: return mail_car_pony_gen_1A_switch_graphics_livery_2_0;
badger: return mail_car_pony_gen_1A_switch_graphics_livery_2_0;
turtle: return mail_car_pony_gen_1A_switch_graphics_livery_2_0;
return mail_car_pony_gen_1A_switch_graphics_livery_1_0;
}
spriteset(mail_car_pony_gen_1A_ss_doors_closed_livery_1_1_unflipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_unflipped(10 + 120)
}
spriteset(mail_car_pony_gen_1A_ss_doors_open_livery_1_1_unflipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_unflipped(10 + 120 + 30)
}
spriteset(mail_car_pony_gen_1A_ss_doors_closed_livery_2_1_unflipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_unflipped(10 + 120 + 60)
}
spriteset(mail_car_pony_gen_1A_ss_doors_open_livery_2_1_unflipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_unflipped(10 + 120 + 90)
}
spritegroup mail_car_pony_gen_1A_sg_livery_1_1_unflipped {
loaded: [
mail_car_pony_gen_1A_ss_doors_closed_livery_1_1_unflipped,
];
loading: [
mail_car_pony_gen_1A_ss_doors_open_livery_1_1_unflipped,
];
}
spritegroup mail_car_pony_gen_1A_sg_livery_2_1_unflipped {
loaded: [
mail_car_pony_gen_1A_ss_doors_closed_livery_2_1_unflipped,
];
loading: [
mail_car_pony_gen_1A_ss_doors_open_livery_2_1_unflipped,
];
}
spriteset(mail_car_pony_gen_1A_ss_doors_closed_livery_1_1_flipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_flipped(10 + 120)
}
spriteset(mail_car_pony_gen_1A_ss_doors_open_livery_1_1_flipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_flipped(10 + 120 + 30)
}
spriteset(mail_car_pony_gen_1A_ss_doors_closed_livery_2_1_flipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_flipped(10 + 120 + 60)
}
spriteset(mail_car_pony_gen_1A_ss_doors_open_livery_2_1_flipped, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_symmetric_unreversed_mail_car_pony_gen_1A_flipped(10 + 120 + 90)
}
spritegroup mail_car_pony_gen_1A_sg_livery_1_1_flipped {
loaded: [
mail_car_pony_gen_1A_ss_doors_closed_livery_1_1_flipped,
];
loading: [
mail_car_pony_gen_1A_ss_doors_open_livery_1_1_flipped,
];
}
spritegroup mail_car_pony_gen_1A_sg_livery_2_1_flipped {
loaded: [
mail_car_pony_gen_1A_ss_doors_closed_livery_2_1_flipped,
];
loading: [
mail_car_pony_gen_1A_ss_doors_open_livery_2_1_flipped,
];
}
// handle user flipped state
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_livery_1_1, vehicle_is_flipped) {
1: return mail_car_pony_gen_1A_sg_livery_2_1_flipped;
return mail_car_pony_gen_1A_sg_livery_1_1_unflipped;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_livery_2_1, vehicle_is_flipped) {
1: return mail_car_pony_gen_1A_sg_livery_1_1_flipped;
return mail_car_pony_gen_1A_sg_livery_2_1_unflipped;
}
switch (FEAT_TRAINS, PARENT, mail_car_pony_gen_1A_switch_graphics_engine_id_1, vehicle_type_id) {
standard: return mail_car_pony_gen_1A_switch_graphics_livery_2_1;
high_flyer: return mail_car_pony_gen_1A_switch_graphics_livery_2_1;
raven: return mail_car_pony_gen_1A_switch_graphics_livery_2_1;
northcock: return mail_car_pony_gen_1A_switch_graphics_livery_2_1;
electra: return mail_car_pony_gen_1A_switch_graphics_livery_2_1;
wizzo: return mail_car_pony_gen_1A_switch_graphics_livery_2_1;
roarer: return mail_car_pony_gen_1A_switch_graphics_livery_2_1;
thunderbird: return mail_car_pony_gen_1A_switch_graphics_livery_2_1;
badger: return mail_car_pony_gen_1A_switch_graphics_livery_2_1;
turtle: return mail_car_pony_gen_1A_switch_graphics_livery_2_1;
return mail_car_pony_gen_1A_switch_graphics_livery_1_1;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_default_DFLT, 0) {
return mail_car_pony_gen_1A_switch_graphics_engine_id_1;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_first_check_length_DFLT, num_vehs_in_vehid_chain) {
0..4: return mail_car_pony_gen_1A_switch_graphics_position_default_DFLT;
return mail_car_pony_gen_1A_switch_graphics_engine_id_1;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_check_first_DFLT, position_in_vehid_chain) {
0: return mail_car_pony_gen_1A_switch_graphics_position_first_check_length_DFLT;
mail_car_pony_gen_1A_switch_graphics_position_default_DFLT;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_check_last_DFLT, position_in_vehid_chain_from_end) {
0: return mail_car_pony_gen_1A_switch_graphics_engine_id_1;
mail_car_pony_gen_1A_switch_graphics_position_check_first_DFLT;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_in_consist_entry_point_DFLT, 0) {
return mail_car_pony_gen_1A_switch_graphics_position_check_last_DFLT;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_default_PASS, 0) {
return mail_car_pony_gen_1A_switch_graphics_engine_id_0;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_first_check_length_PASS, num_vehs_in_vehid_chain) {
0..4: return mail_car_pony_gen_1A_switch_graphics_position_default_PASS;
return mail_car_pony_gen_1A_switch_graphics_engine_id_0;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_check_first_PASS, position_in_vehid_chain) {
0: return mail_car_pony_gen_1A_switch_graphics_position_first_check_length_PASS;
mail_car_pony_gen_1A_switch_graphics_position_default_PASS;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_check_last_PASS, position_in_vehid_chain_from_end) {
0: return mail_car_pony_gen_1A_switch_graphics_engine_id_0;
mail_car_pony_gen_1A_switch_graphics_position_check_first_PASS;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_in_consist_entry_point_PASS, 0) {
return mail_car_pony_gen_1A_switch_graphics_position_check_last_PASS;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_default_MAIL, 0) {
return mail_car_pony_gen_1A_switch_graphics_engine_id_1;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_first_check_length_MAIL, num_vehs_in_vehid_chain) {
0..4: return mail_car_pony_gen_1A_switch_graphics_position_default_MAIL;
return mail_car_pony_gen_1A_switch_graphics_engine_id_1;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_check_first_MAIL, position_in_vehid_chain) {
0: return mail_car_pony_gen_1A_switch_graphics_position_first_check_length_MAIL;
mail_car_pony_gen_1A_switch_graphics_position_default_MAIL;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_check_last_MAIL, position_in_vehid_chain_from_end) {
0: return mail_car_pony_gen_1A_switch_graphics_engine_id_1;
mail_car_pony_gen_1A_switch_graphics_position_check_first_MAIL;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_position_in_consist_entry_point_MAIL, 0) {
return mail_car_pony_gen_1A_switch_graphics_position_check_last_MAIL;
}
switch (FEAT_TRAINS, PARENT, mail_car_pony_gen_1A_switch_graphics_unreversed, most_common_cargo_type) {
PASS: return mail_car_pony_gen_1A_switch_graphics_position_in_consist_entry_point_PASS;
MAIL: return mail_car_pony_gen_1A_switch_graphics_position_in_consist_entry_point_MAIL;
return mail_car_pony_gen_1A_switch_graphics_position_in_consist_entry_point_DFLT;
}
// buy menu graphics chain
spriteset(mail_car_pony_gen_1A_ss_purchase, "generated/graphics/mail_car_pony_gen_1A.png") {
spriteset_template_purchase_mail_car_pony_gen_1A(10)
}
spritegroup mail_car_pony_gen_1A_sg_purchase {
loaded: [
mail_car_pony_gen_1A_ss_purchase,
];
loading: [
mail_car_pony_gen_1A_ss_purchase,
];
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_graphics_purchase, 0) {
return mail_car_pony_gen_1A_sg_purchase;
}
// -- capacity determined according to specific labels that might need to be handled, and otherwise cargo class -- //
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_cargo_capacity_by_cargo_0, cargo_classes & bitmask(CC_PASSENGERS, CC_MAIL, CC_ARMOURED)) {
bitmask(CC_MAIL): return 14;
bitmask(CC_ARMOURED): return 14;
return 7;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_cargo_capacity_by_cargo_1, cargo_classes & bitmask(CC_PASSENGERS, CC_MAIL, CC_ARMOURED)) {
bitmask(CC_MAIL): return 20;
bitmask(CC_ARMOURED): return 20;
return 10;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_cargo_capacity_by_cargo_2, cargo_classes & bitmask(CC_PASSENGERS, CC_MAIL, CC_ARMOURED)) {
bitmask(CC_MAIL): return 28;
bitmask(CC_ARMOURED): return 28;
return 14;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_cargo_capacity, param[0]) {
0: mail_car_pony_gen_1A_switch_cargo_capacity_by_cargo_0;
1: mail_car_pony_gen_1A_switch_cargo_capacity_by_cargo_1;
2: mail_car_pony_gen_1A_switch_cargo_capacity_by_cargo_2;
}
// -- loading speed also determined by capacity, which varies by cargo -- //
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_loading_speed_by_cargo_0, cargo_classes & bitmask(CC_PASSENGERS, CC_MAIL, CC_ARMOURED)) {
bitmask(CC_PASSENGERS): return 2;
bitmask(CC_MAIL): return 2;
bitmask(CC_ARMOURED): return 2;
return 2;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_loading_speed_by_cargo_1, cargo_classes & bitmask(CC_PASSENGERS, CC_MAIL, CC_ARMOURED)) {
bitmask(CC_PASSENGERS): return 2;
bitmask(CC_MAIL): return 2;
bitmask(CC_ARMOURED): return 2;
return 2;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_loading_speed_by_cargo_2, cargo_classes & bitmask(CC_PASSENGERS, CC_MAIL, CC_ARMOURED)) {
bitmask(CC_PASSENGERS): return 3;
bitmask(CC_MAIL): return 3;
bitmask(CC_ARMOURED): return 3;
return 3;
}
switch (FEAT_TRAINS, SELF, mail_car_pony_gen_1A_switch_loading_speed, param[0]) {
0: mail_car_pony_gen_1A_switch_loading_speed_by_cargo_0;
1: mail_car_pony_gen_1A_switch_loading_speed_by_cargo_1;
2: mail_car_pony_gen_1A_switch_loading_speed_by_cargo_2;
}
item(FEAT_TRAINS, mail_car_pony_gen_1A, 2280) {
property {
name: string(STR_NAME_CONSIST, string(STR_NAME_SUFFIX_MAIL_CAR), string(STR_NAME_SUFFIX_SMALL));
climates_available: NO_CLIMATE; // nml constant
engine_class: ENGINE_CLASS_STEAM;
visual_effect_and_powered: visual_effect_and_powered(VISUAL_EFFECT_DISABLE, 0, DISABLE_WAGON_POWER);
introduction_date: date(1860,01,01); // consist just supplies intro year - openttd randomises intro dates a bit anyway
cargo_capacity: 10;
sprite_id: SPRITE_ID_NEW_TRAIN; //enable new graphics - nml constant
power: 0hp;
speed: 65mph;
weight: 5.0ton;
tractive_effort_coefficient: 0.3;
cost_factor: 40.0;
running_cost_base: RUNNING_COST_STEAM;
running_cost_factor: 9.285714285714286;
refit_cost: 0; // btw this needs to be 0 if we want autorefit without using cb
refittable_cargo_classes: bitmask(CC_MAIL,CC_EXPRESS,CC_ARMOURED);
non_refittable_cargo_classes: bitmask(); // don't set non-refittable classes, increases likelihood of breaking cargo support
cargo_allow_refit: [];
cargo_disallow_refit: [TOUR];
cargo_age_period: 185;
default_cargo_type: MAIL;
misc_flags: bitmask(TRAIN_FLAG_2CC,TRAIN_FLAG_FLIP,TRAIN_FLAG_AUTOREFIT); // nml constants
dual_headed: 0;
model_life: 40;
retire_early: -10;
reliability_decay: 20; // default value
vehicle_life: 40;
length: 4;
track_type: RAIL;
}
graphics {
default: mail_car_pony_gen_1A_switch_graphics_unreversed;
purchase: mail_car_pony_gen_1A_switch_graphics_purchase;
cargo_capacity: mail_car_pony_gen_1A_switch_cargo_capacity;
purchase_cargo_capacity: mail_car_pony_gen_1A_switch_cargo_capacity;
loading_speed: mail_car_pony_gen_1A_switch_loading_speed;
}
}
if (param[1]==0) {
item(FEAT_TRAINS, mail_car_pony_gen_1A, 2280) {
property {
climates_available: ALL_CLIMATES;
}
}
}
// -- end 2280 --
User avatar
FulliAutomatix
Engineer
Engineer
Posts: 119
Joined: 24 Aug 2014 12:20
Location: Kaon Prison, Cybertron

Re: Changing livery depending on cargo

Post by FulliAutomatix »

Ta very much :D
I'll try test this out at some point
User avatar
FulliAutomatix
Engineer
Engineer
Posts: 119
Joined: 24 Aug 2014 12:20
Location: Kaon Prison, Cybertron

Re: Changing livery depending on cargo

Post by FulliAutomatix »

andythenorth wrote:However before you read all that...you might want a new version of nml :D
http://dev.openttdcoop.org/projects/nml ... 8e468b64dd
I'm having some trouble finding a download that will give me a working version, could you give me a direct download link to the latest nmlc.exe bundle with the patch you speak of please? I'm on Windows
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5658
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Changing livery depending on cargo

Post by andythenorth »

FulliAutomatix wrote:I'm having some trouble finding a download that will give me a working version, could you give me a direct download link to the latest nmlc.exe bundle with the patch you speak of please? I'm on Windows
I don't know how the Windows exe is built, but the installation docs are here https://www.tt-wiki.net/wiki/NMLTutoria ... Easy_route

They suggest you can get the download here http://bundles.openttdcoop.org/nml/nightlies/LATEST/

The date on the zip looks right. Hope it works :)
User avatar
FulliAutomatix
Engineer
Engineer
Posts: 119
Joined: 24 Aug 2014 12:20
Location: Kaon Prison, Cybertron

Re: Changing livery depending on cargo

Post by FulliAutomatix »

andythenorth wrote:
FulliAutomatix wrote:I'm having some trouble finding a download that will give me a working version, could you give me a direct download link to the latest nmlc.exe bundle with the patch you speak of please? I'm on Windows
I don't know how the Windows exe is built, but the installation docs are here https://www.tt-wiki.net/wiki/NMLTutoria ... Easy_route

They suggest you can get the download here http://bundles.openttdcoop.org/nml/nightlies/LATEST/

The date on the zip looks right. Hope it works :)
Aight, I got it and it's working for me, thanks!
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Bing [Bot], Google Adsense [Bot] and 71 guests