Help for NML

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

Moderator: Graphics Moderators

Post Reply
Telk
Engineer
Engineer
Posts: 64
Joined: 05 May 2008 14:04
Location: Seoul, South Korea
Contact:

Help for NML

Post by Telk »

Hello
I think NML is a very good tool to make NewGRF and thanks for developer.

In this time, I have a problem with applying something.
I want this:
1. Add a locomotive.
2. Add a default passenger wagon behind that.
3. Then passenger wagon's graphic changes according to locomotive.
(Is this called 'livery override'?)


NML Documents(http://newgrf-specs.tt-wiki.net/wiki/NM ... y_override) say

Code: Select all

livery_override (vehicleID) {
	callback_name: switch_name;
	callback_name2: return value;
	default: spritegroup_name;
}

I tried to make an engine ('KTX' in screenshot) and attached that codes just behind graphics block.
But it doesn't apply to game.

I know that I'm bothering you but please see my NML codes and what is the problem with my codes.


Here's Screenshots
liveryoverride.png
(96.23 KiB) Downloaded 3 times
(The above one is the result that I made. And the below one is what I intend.)

Code: Select all

grf {
	grfid : "TK\05\01";
	name : string(STR_GRF_NAME);
	desc : string(STR_GRF_DESC);
	version : 1;
	min_compatible_version : 1;
}

railtypetable {
	ELRL
}

template tmpl_vehicle_basic(x, y) {
	//xpos	ypos	xsize	ysize	xoff	yoff
	[x,	y,	 8,	22,	 -3,	-12]
	[x +  9,	y,	22,	16,	-14,	-10]
	[x + 32,	y,	32,	12,	-16,	 -6]
	[x + 65,	y,	22,	16,	 -6,	-10]
}

template tmpl_vehicle_4_views(line_num) {
	tmpl_vehicle_basic(1,	30 * line_num)
}

template tmpl_vehicle_8_views(line_num) {
	tmpl_vehicle_basic(1,	30 * line_num)
	tmpl_vehicle_basic(89,	30 * line_num)
}


spriteset(set_ktx_engine_f,		"./tk_KTX/gfx/rKTX.png") { tmpl_vehicle_8_views(0) }
spriteset(set_ktx_middle_r,		"./tk_KTX/gfx/rKTX.png") { tmpl_vehicle_8_views(2) }
spriteset(set_ktx_center,		"./tk_KTX/gfx/rKTX.png") { tmpl_vehicle_4_views(4) }
spriteset(set_ktx_center2,		"./tk_KTX/gfx/rKTX.png") { tmpl_vehicle_8_views(4) }
spriteset(set_ktx_middle_f,		"./tk_KTX/gfx/rKTX.png") { tmpl_vehicle_8_views(3) }
spriteset(set_ktx_engine_r,		"./tk_KTX/gfx/rKTX.png") { tmpl_vehicle_8_views(1) }

spriteset(set_ktx_purchase_f,		"./tk_KTX/gfx/rKTX.png") { [121, 0, 32, 12, -24, -4] }
spriteset(set_ktx_purchase_r,		"./tk_KTX/gfx/rKTX.png") { [33, 0, 32, 12, -24, -4] }
spriteset(set_ktx_invisible,		"./tk_KTX/gfx/rKTX.png") { [1, 180, 1, 1, 0, 0] }
spriteset(set_ktx_middle_purchase,	"./tk_KTX/gfx/rKTX.png") { [33, 120, 32, 12, -24, -4] }


// Sprites
switch(FEAT_TRAINS, SELF, sw_ktx_middle2, cargo_subtype) {
	set_ktx_center;
}
switch(FEAT_TRAINS, SELF, sw_ktx_middle1, position_in_consist_from_end) {
	0: set_ktx_engine_f;
	1: set_ktx_middle_f;
	sw_ktx_middle2;
}
switch(FEAT_TRAINS, SELF, sw_ktx_graphics, position_in_consist) {
	0: set_ktx_engine_f;
	1: set_ktx_middle_f;
	sw_ktx_middle1;
}

switch(FEAT_TRAINS, SELF, sw_ktx_can_attach_wagon, vehicle_type_id) {
	train_ktx: return CB_RESULT_ATTACH_ALLOW;
	return string(STR_KTX_ERROR_CANNOT_ATTACH_OTHER);
}

// Define a KTX train
item(FEAT_TRAINS, train_ktx) {
	property {
		name:				string(STR_KTX_NAME);
		climates_available:		ALL_CLIMATES & ~bitmask(CLIMATE_TOYLAND);

		introduction_date:		date(2000, 1, 1);
		model_life:			VEHICLE_NEVER_EXPIRES;
		vehicle_life:			30;
		reliability_decay:			1;
		refittable_cargo_classes:		bitmask(CC_PASSENGERS);
		non_refittable_cargo_classes:	bitmask();
		loading_speed:			20;
		cost_factor:			1;
		running_cost_factor:		100;
		sprite_id:				SPRITE_ID_NEW_TRAIN;
		speed:				330 km/h;

//		misc_flags:			bitmask(TRAIN_FLAG_MU);
		misc_flags:			bitmask(TRAIN_FLAG_TILT, TRAIN_FLAG_2CC, TRAIN_FLAG_MU, TRAIN_FLAG_AUTOREFIT);

		refit_cost:			0;

		track_type:			ELRL;
		ai_special_flag:			AI_FLAG_PASSENGER;
		power:				1130 kW;
		running_cost_base:		RUNNING_COST_ELECTRIC;
		dual_headed:			1;
		cargo_capacity:			58;
		weight:				17 ton;
		engine_class:			ENGINE_CLASS_ELECTRIC;
		extra_power_per_wagon:		0 kW;
		tractive_effort_coefficient:		1;
		visual_effect_and_powered:		VISUAL_EFFECT_ELECTRIC;

		// Overridden by callback to disable for non-powered wagons:
//		visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 0, ENABLE_WAGON_POWER);
		extra_weight_per_wagon:       0 ton;
		bitmask_vehicle_info:         0;
	}

	// define graphics
	graphics {
		default:			sw_ktx_graphics;
		purchase:			set_ktx_purchase_f;
//		articulated_part:		sw_ktx_articulated_part;
//		start_stop:		sw_ktx_start_stop;
//		can_attach_wagon:		sw_ktx_can_attach_wagon;
//		speed:			sw_ktx_speed;
	}

	// I heard that the default passenger wagon's vehicleID is 27 from http://newgrf-specs.tt-wiki.net/wiki/NML:List_of_default_vehicle_IDs
	livery_override(27) {
		default:			set_ktx_center;
	}
}
Image
- OpenTTD/OpenRCT2/Parkitect Korean Translator
- TELKLAND site manager, the korean website of OpenRCT2/OpenTTD (https://telk.kr)
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Help for NML

Post by Yexo »

A livery override works the opposite way. You have to put the livery_override block in the item-block of the wagon, not the item-block of the engine. Because of this you'll need to also add a wagon to your grf to get this to work. The parameter for the livery_override-block is the id of the engine.
Telk
Engineer
Engineer
Posts: 64
Joined: 05 May 2008 14:04
Location: Seoul, South Korea
Contact:

Re: Help for NML

Post by Telk »

Yexo wrote:A livery override works the opposite way. You have to put the livery_override block in the item-block of the wagon, not the item-block of the engine. Because of this you'll need to also add a wagon to your grf to get this to work. The parameter for the livery_override-block is the id of the engine.

Thanks for your help. It was very amazing to me.


By the way, if you have a more time could you answer me one more?

NML Tutorial teaches only making an engine.
Then how to make wagon?

Which option should I except in property-block of engine's?
Image
- OpenTTD/OpenRCT2/Parkitect Korean Translator
- TELKLAND site manager, the korean website of OpenRCT2/OpenTTD (https://telk.kr)
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Help for NML

Post by FooBar »

If so, then both the documentation and the example are wrong. I'm a bit hesitant towards updating those, as I've never workt with livery overrides.

@Telk: making a wagon is basically the same as making an engine. Just set power to 0. And there are probably some other things that you don't need either, like tractive effort. Here's an example from the Dutch Trainset: http://dev.openttdcoop.org/projects/dut ... _item.pnml
From there you can also find an example for engine-dependent wagon graphics without the livery override block, e.g. this: http://dev.openttdcoop.org/projects/dut ... .pnml#L156 That file does many things more, but look specifically at lines 156-160.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Help for NML

Post by Yexo »

FooBar wrote:If so, then both the documentation and the example are wrong. I'm a bit hesitant towards updating those, as I've never workt with livery overrides.
Hmm, I can't believe both are wrong, so please ignore my previous post.

I do think however that a livery override only works when both wagon and engine are defined in your own newgrf, that could be another reason why it doesn't work.
Eddi
Tycoon
Tycoon
Posts: 8272
Joined: 17 Jan 2007 00:14

Re: Help for NML

Post by Eddi »

i don't think this is true, because then things like the turbotrain or chimera GRF woudln't work.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 19 guests