Parameter not showing up and unusable

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

Moderator: Graphics Moderators

Post Reply
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Parameter not showing up and unusable

Post by Erato »

Hello,

I am currently trying to make a parameter which sets how high the train is shown, because the trains look off in the FS-maglev track set, but if I adapt the train-height to the FS-set, the train looks weird on normal rails. To achieve this, I used the following code to set the parameter:

Code: Select all

	param {
        param_height {
            type:   int;
            name:   string(STR_PARAM_RAILHEIGHT);
            desc:   string(STR_PARAM_RAILHEIGHT_DESC);
            min_value: 0;
            max_value: 1;
            def_value: 0;
            names: {
                        0: string(STR_PARAM_RAILHEIGHT_ST);
                        1: string(STR_PARAM_RAILHEIGHT_FS);
            };
        }
    }
and then the following code to use it:

Code: Select all

template TEMP_TRAIN_DOUBLE_8(h,d) {
	[0, 0, 8, 22+h+d, -3, -14-h-(4*param_height)]
	[9, 0, 22, 17+h+d, -14, -7-h-(4*param_height)]
	[32, 0, 32, 12+h+d, -15, -6-h-(4*param_height)]
	[65, 0, 22, 17+h+d, -8, -7-h-(4*param_height)]
	[88, 0, 8, 22+h+d, -3, -14-h-(4*param_height)]
	[97, 0, 22, 17+h+d, -14, -7-h-(4*param_height)]
	[120, 0, 32, 12+h+d, -15, -6-h-(4*param_height)]
	[153, 0, 22, 17+h+d, -8, -7-h-(4*param_height)]
}
The latter block of code causes the compiler to return this:

Code: Select all

nmlc ERROR: "src/template.pnml", line 209: Unrecognized identifier 'param_height' encountered
and if I change the template to not use the parameter, I find that the parameter is completely missing from the list.

What am I doing wrong?
No pics no clicks. Seriously.
ImageImageImageImageImageImage
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Parameter not showing up and unusable

Post by planetmaker »

Why don't skip the parameter and simply include both offsets (thus the sprite two times, once with each offset) and show the appropriate one, depending on the tracktype?
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: Parameter not showing up and unusable

Post by Erato »

planetmaker wrote:Why don't skip the parameter and simply include both offsets (thus the sprite two times, once with each offset) and show the appropriate one, depending on the tracktype?
Well, there is really only 1 tracktype: Maglev, and the FS-track replaces the maglev track, thus effectively making it so that I can't change the offset depending on the tracktype, unfortunately.
No pics no clicks. Seriously.
ImageImageImageImageImageImage
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Parameter not showing up and unusable

Post by planetmaker »

Erato wrote:
planetmaker wrote:Why don't skip the parameter and simply include both offsets (thus the sprite two times, once with each offset) and show the appropriate one, depending on the tracktype?
Well, there is really only 1 tracktype: Maglev, and the FS-track replaces the maglev track, thus effectively making it so that I can't change the offset depending on the tracktype, unfortunately.
That's a design error in the tracks then: if the *same* track label requires differently coded vehicles, then the error is with the track. Use different track labels, if the vehicles need to be coded differently.
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: Parameter not showing up and unusable

Post by Erato »

planetmaker wrote:
Erato wrote:
planetmaker wrote:Why don't skip the parameter and simply include both offsets (thus the sprite two times, once with each offset) and show the appropriate one, depending on the tracktype?
Well, there is really only 1 tracktype: Maglev, and the FS-track replaces the maglev track, thus effectively making it so that I can't change the offset depending on the tracktype, unfortunately.
That's a design error in the tracks then: if the *same* track label requires differently coded vehicles, then the error is with the track. Use different track labels, if the vehicles need to be coded differently.
I can unfortunately not change the way the track is coded:

Code: Select all

	//RT labels
	-1 * 0	04 06 FF 01 00 D0 "Maglev Construction" 00 // in case you need these changed
	-1 * 0	04 06 FF 01 01 D0 "FS-Maglev Tracks" 00
	
	-1 * 0	00 10 05 01 01 
		08 "MGLV"	//replace maglev tracks - RAIL for normal rail, ELRL for electrified rail and MONO for monorail
		09 00 D0	//build rail toolbar caption - see RT labels
		0A 00 D0	//rail construction dropdown text  - see RT labels
		10 02		//disable level crossings
		1B 01 D0	//railtype name  - see RT labels
Looks to me like it completely replaces the maglev track without getting a new track label.

But then remains the problem that I can't set or use the parameter. And I would like to know what I did wrong so next time I try it it won't have to make a new thread.
No pics no clicks. Seriously.
ImageImageImageImageImageImage
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Parameter not showing up and unusable

Post by planetmaker »

Erato wrote: But then remains the problem that I can't set or use the parameter. And I would like to know what I did wrong so next time I try it it won't have to make a new thread.
I would query the presence of that particular NewGRF instead and adjust template depending on the outcome ;)

Unfortunately I don't quite see what could be wrong with the code you showed and I would have guessed that it works as you think it should work. Do you have other parameters? Do they work?
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: Parameter not showing up and unusable

Post by Erato »

planetmaker wrote:
Erato wrote: But then remains the problem that I can't set or use the parameter. And I would like to know what I did wrong so next time I try it it won't have to make a new thread.
I would query the presence of that particular NewGRF instead and adjust template depending on the outcome ;)

Unfortunately I don't quite see what could be wrong with the code you showed and I would have guessed that it works as you think it should work. Do you have other parameters? Do they work?
I was thinking about that but I don't really know how to do that. Would that require a switch-case for the grf-id of the FS-maglev track set?

Why yes, I do have other parameters, and they do work, however, they are boolean, instead of drop-down.
Code:
[+] Spoiler

Code: Select all

#define JAPAN param_japan
#define GERMANY param_germany
#define SOVIET param_soviet
#define UK param_uk
#define SK param_sk
#define CHINA param_china
#define BRAZIL param_brazil
#define US param_us
#define RAILHEIGHT param_height
//#define VENEZUELA param_venezuela

#define NOREGION 0

#define REGION(REGION1,REGION2) climates_available: (REGION1 || REGION2) ? ALL_CLIMATES : NO_CLIMATE

grf {
	grfid:	"EN\01\01";
	name:	string(STR_GRF_NAME);
	desc:	string(STR_GRF_DESC);
	version:	4;
	min_compatible_version: 4;
	param {
        param_height {
            type:   int;
            name:   string(STR_PARAM_RAILHEIGHT);
            desc:   string(STR_PARAM_RAILHEIGHT_DESC);
            min_value: 0;
            max_value: 1;
            def_value: 0;
            names: {
                        0: string(STR_PARAM_RAILHEIGHT_ST);
                        1: string(STR_PARAM_RAILHEIGHT_FS);
            };
        }
    }
	param {
		JAPAN {
			type:	bool;
			name:	string(STR_PARAM_JAPAN);
			desc:	string(STR_PARAM_JAPAN_DESC);
			def_value: 1;
		}
	}
	param {
		GERMANY {
			type:	bool;
			name:	string(STR_PARAM_GERMANY);
			desc:	string(STR_PARAM_GERMANY_DESC);
			def_value: 1;
		}
	}
	param {
		US {
			type:	bool;
			name:	string(STR_PARAM_US);
			desc:	string(STR_PARAM_US_DESC);
			def_value: 1;
		}
	}
	param {
		SK {
			type:	bool;
			name:	string(STR_PARAM_SK);
			desc:	string(STR_PARAM_SK_DESC);
			def_value: 1;
		}
	}
	param {
		CHINA {
			type:	bool;
			name:	string(STR_PARAM_CHINA);
			desc:	string(STR_PARAM_CHINA_DESC);
			def_value: 1;
		}
	}
	param {
		SOVIET {
			type:	bool;
			name:	string(STR_PARAM_SOVIET);
			desc:	string(STR_PARAM_SOVIET_DESC);
			def_value: 1;
		}
	}
	param {
		UK {
			type:	bool;
			name:	string(STR_PARAM_UK);
			desc:	string(STR_PARAM_UK_DESC);
			def_value: 1;
		}
	}
	param {
		BRAZIL {
			type:	bool;
			name:	string(STR_PARAM_BRAZIL);
			desc:	string(STR_PARAM_BRAZIL_DESC);
			def_value: 1;
		}
	}
}
Edit, interestingly enough, the parameter did show up after I removed and readded the grf to the NewGRF settings.

Still doesn't explain why I couldn't use it in the code.
No pics no clicks. Seriously.
ImageImageImageImageImageImage
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: Parameter not showing up and unusable

Post by michael blunck »

Erato wrote: [...] Still doesn't explain why I couldn't use it in the code.
I don´t think it could work that way.

What you´re trying to do boils down to change a value in an action1 (y-offset in that "template") but this can´t be done "dynamically", i.e. not even by use of a callback.

So, what you need to do is to set up two sprite blocks with different offsets and switch them depending on your parameter, as planetmaker suggested.

regards
Michael
Image
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests