Lawton27's NML problems

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

Moderator: Graphics Moderators

Post Reply
User avatar
lawton27
Tycoon
Tycoon
Posts: 1418
Joined: 03 Aug 2009 14:29
Location: Manchester

Lawton27's NML problems

Post by lawton27 »

Hi there I've been trying to make my train articulated, so so far I've coded up an articulated test train with 2 parts based off the articulated tram example nml. I can't tell anything wrong with my code.

This is the code:

Code: Select all

switch (FEAT_TRAINS, SELF, SudEstHead_articulated_parts, current_callback) {
	1..3:	return 01;
	CB_FAILED;
}

switch (FEAT_TRAINS, SELF, SudEstHead_callbacks, extra_callback_info1) {
	VEH_CB_ARTICULATED_PARTS: SudEstHead_articulated_parts;
	SEFRONT_group;
}


item (FEAT_TRAINS, SudEstHead) {
	property {
		sprite_id:          SPRITE_ID_NEW_TRAIN;
		misc_flags:  	    bitmask(TRAIN_FLAG_2CC);
		track_type:         ELRL;
		name:               string(STR_NAME_SUD_EST);
		climates_available: ALL_CLIMATES;
		introduction_date:  date(1981,1,1);
		speed:              168 mph;
		tractive_effort_coefficient:    0.5;
		air_drag_coefficient: 0;
		power:              9245 hp;
		dual_headed:        0;
		engine_class:       ENGINE_CLASS_ELECTRIC;
		cargo_capacity:     0;
		weight: 179; // half offical weight, only one end
		reliability_decay: 12;
		model_life: 32;
		vehicle_life: 45;
		cost_factor: 50;
		running_cost_factor: 50;
		callback_flags:	bitmask(VEH_CBF_ARTICULATED_PARTS);
	}
	graphics
        {                           // graphics for engine
		 SudEstHead_callbacks;
	}
}

item (FEAT_TRAINS, SudEstFirst, 01) {
	property {
		sprite_id:          SPRITE_ID_NEW_TRAIN;
		misc_flags:  	    bitmask(TRAIN_FLAG_2CC);

		track_type:         ELRL;
		name:               string(STR_NAME_SUD_EST);
		climates_available: NO_CLIMATE;
		introduction_date:  date(1920,1,1);
		speed:              168 mph;
		tractive_effort_coefficient:    0.5;
		air_drag_coefficient: 0;
		power:              0;
		dual_headed:        0;
		engine_class:       ENGINE_CLASS_ELECTRIC;
		cargo_capacity:     0;
		refittable_cargo_types: bitmask(PASS, TOUR);
		weight: 13;
		loading_speed: 20;
		cost_factor: 50;
	}
	graphics 
        {                           // graphics for engine
		SEFIRST_group;
	}
}

What happens when I try the newGRF is the train from SudEstHead is available in the purchase menu and used the sprites from SEFRONT_group, but when I purchase it no articulated parts are attached, it still used the right sprites, the articulated part is definitely not present it doesn't show up in the vehicle consist information box.

Thanks for any help you can provide,

Lawton27
Last edited by lawton27 on 18 Apr 2011 17:49, edited 1 time in total.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML problem - articulated trains.

Post by Yexo »

lawton27 wrote:

Code: Select all

switch (FEAT_TRAINS, SELF, SudEstHead_callbacks, extra_callback_info1) {
You're testing for extra_callback_info1 instead of current_callback.
User avatar
lawton27
Tycoon
Tycoon
Posts: 1418
Joined: 03 Aug 2009 14:29
Location: Manchester

Re: NML problem - articulated trains.

Post by lawton27 »

Yexo wrote: You're testing for extra_callback_info1 instead of current_callback.
Ah silly me, I got the extra_callback_info1 and current_callback the wrong way round, thanks that worked.
User avatar
lawton27
Tycoon
Tycoon
Posts: 1418
Joined: 03 Aug 2009 14:29
Location: Manchester

Re: Lawton27's NML problems

Post by lawton27 »

Hello again, I've got a new problem again I've followed what I read on the documentation but I'm having some problems getting parameters to work, this is my parameter code:

Code: Select all

param {
	EnableTGV {
		type:	bool;
		name:	string(STR_PARAM_ENABLE_TGVS);
		desc:	string(STR_PARAM_ENABLE_TGVS_DESC);
		def_value:	1;
	}
}
but for some reason I'm getting an error on the first line ("param {") of;

Code: Select all

nmlc: "input", line 11: Syntax error, unexpected token "{"
I've probably done something stupid again, thanks for any help.
Last edited by lawton27 on 18 Apr 2011 17:59, edited 1 time in total.
User avatar
YukonRob
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 31 Jul 2007 00:58
Location: North of 63

Re: Lawton27's NML problems

Post by YukonRob »

Can't help, but your error report has 3 quotes ("), never a good sign.
User avatar
lawton27
Tycoon
Tycoon
Posts: 1418
Joined: 03 Aug 2009 14:29
Location: Manchester

Re: Lawton27's NML problems

Post by lawton27 »

Ah, my bad, that's just a typo in my post, I'll change that.
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Re: Lawton27's NML problems

Post by Michi_cc »

Read the very first sentence of http://hg.openttdcoop.org/nml/raw-file/ ... f-settings

-- Michael Lutz
User avatar
YukonRob
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 31 Jul 2007 00:58
Location: North of 63

Re: Lawton27's NML problems

Post by YukonRob »

In researching Michael's suggestion where I believe he is alluding to ensuring that the param is in the grf block I found the following on the wiki:

Code: Select all

grf {
	grfid: <literal-string>;
	name: <string>;
	desc: <string>;
	version: <expression>;
	min_compatible_version: <expression>;
	<param { ... }>
}
Is the leading '<' in front of the param correct?
User avatar
lawton27
Tycoon
Tycoon
Posts: 1418
Joined: 03 Aug 2009 14:29
Location: Manchester

Re: Lawton27's NML problems

Post by lawton27 »

That worked, silly me, thanks.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Lawton27's NML problems

Post by planetmaker »

YukonRob wrote:In researching Michael's suggestion where I believe he is alluding to ensuring that the param is in the grf block I found the following on the wiki:

Code: Select all

grf {
	grfid: <literal-string>;
	name: <string>;
	desc: <string>;
	version: <expression>;
	min_compatible_version: <expression>;
	<param { ... }>
}
Is the leading '<' in front of the param correct?
No. But this way of writing is meant to indicate that the param block is an optional part of the grf block which is explained separately
User avatar
lawton27
Tycoon
Tycoon
Posts: 1418
Joined: 03 Aug 2009 14:29
Location: Manchester

Re: Lawton27's NML problems

Post by lawton27 »

Hello again, today I'm having problems testing for newGRFs and changing rail types as a result, I'm trying to detect NuTracks and if it is present set a certain train to Track Planning for testing and otherwise set it as ELRL, here is my NML;

Code: Select all

railtypetable {
	ELRL, PLAN
}

if(grf_current_status("\44\4A\54\01")){
	param[64] = 02;
}else{
	param[64] = 01;
}
I have my train's track type set to param[64], when NuTracks is present it works as expected and I get my train on the planning track type, however when NuTracks is not active the train is not available at all...

Thanks for any help you can offer,

Lawton27
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: Lawton27's NML problems

Post by Hirundo »

I think it would be more appropriate to check for the existence of the planning track, instead of checking for NuTracks. After all, NuTracks may not supply the planning tracks you expect, or other grfs may define the planning tracks even when NuTracks is not loaded.

The function railtype_available("LABL") should fill your needs.

Also it would be better to refer to your rail types via the label, instead of the index. NML can do the counting, no need to it yourself. Like this:

Code: Select all

param[64] = PLAN;
Create your own NewGRF? Check out this tutorial!
User avatar
lawton27
Tycoon
Tycoon
Posts: 1418
Joined: 03 Aug 2009 14:29
Location: Manchester

Re: Lawton27's NML problems

Post by lawton27 »

Thanks for the advice that's a better way of doing it, however it still won't work, I'm starting to think it's because of something else I've done, when I use this code:

Code: Select all

if(railtype_available("PLAN")){
	param[64] = PLAN;
} else {
	param[64] = ELRL;
}
The train is only ever available on ELRL and never PLAN regardless of if it is active or not...
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: Lawton27's NML problems

Post by Hirundo »

:idea: I should've seen this earlier, but somehow didn't. /facepalm

Parameters 64 - 127 are reserved by NML for internal calculations. These internal calculations probably override the value you set. Try using a different param number. (<64)
Create your own NewGRF? Check out this tutorial!
User avatar
lawton27
Tycoon
Tycoon
Posts: 1418
Joined: 03 Aug 2009 14:29
Location: Manchester

Re: Lawton27's NML problems

Post by lawton27 »

That works, thanks, I thought 64 might be a good point to start counting my rail type parameters from, obviously not :lol:

Perhaps the NML compiler should have a built in warning when you compile, like when you create something which you do not reference, along the lines of:

Code: Select all

Warning on Line XXX there is a reference to parameter XXX, parameters 64 - 127 are reserved for nml internal calculations
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 8 guests