[NML] Compiling error: Syntax error, unexpected token "}"

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
Abydos
Engineer
Engineer
Posts: 20
Joined: 18 Dec 2016 01:51
Location: Rio de Janeiro, Brazil

[NML] Compiling error: Syntax error, unexpected token "}"

Post by Abydos »

I'm trying to compile an .nml file from a locomotive, but I'm getting an upcoming text when trying to compile it in nmlc:

Code: Select all

← [Knmlc ERROR: "D:/bts/locomotiva.nml", line 55: Syntax error, unexpected token "}"
I've already tried to review if all the methods are properly closed, and I could not solve the problem. If I try to change the position of this closing bracket, the nmlc will point error to the if, else or graphics parameter, depending on where I put it.

PS: Line 55 is the "property" closing bracket, before the "if".

My code:

Code: Select all

// Name:	  	     ALL GP22U
// Description:		This .nml file contains data of ALL GP22U locomotive;
// Version:		      0.1 - Thursday, July 27, 2017;
// Author:	  		Abydos;
// Licence:	  		GPLv2.		 

// Sprites, coordinates and sprite groups;

spriteset (all_gp22u, "bts/gfx/gp22u_all.png")
{
    //left_x, upper_y, width, height, offset_x, offset_y
    [0,      0,        8,    26,      -3,       -10]
    [9,      0,       22,    21,     -14,        -7]
    [32,     0,       32,    13,     -14,        -6]
    [65,     0,       22,    21,      -6,        -7]
    [88,     0,        8,    26,      -3,       -10]
    [97,     0,       22,    21,     -14,        -7]
    [120,    0,       32,    13,     -14,        -6]
    [153,    0,       22,    21,      -6,        -7]
}

spriteset (all_gp22u_purchase, "bts/gfx/gp22u_all.png")
{
	//left_x, upper_y, width, height, offset_x, offset_y
    [120,    0,       32,    13,     -14,        -6]
}

// Locomotive properties and data;

item(FEAT_TRAINS, item_allgp22u)
{
	property
	{
		name:							string(STR_GP22UALL_NAME);
		climates_available: 			ALL_CLIMATES & bitmask(CLIMATE_TOYLAND);
		introduction_date:              date(1997, 1, 1);								
		vehicle_life:					30;												
		reliability_decay:				20;												
		loading_speed:					5;												
		cost_factor:					PURCHASE_COST_GP22U_ALL;						
		running_cost_factor:			RUNNING_COST_GP22U_ALL;							
		sprite_id: 						SPRITE_ID_NEW_TRAIN;							
		speed:							97 km/h;										
		misc_flags:						bitmask(TRAIN_FLAG_FLIP);						
		refit_cost:						0;												
		track_type:						RAIL;											
		ai_special_flag:				AI_FLAG_CARGO;									
		power:							1650 hp; 										
		running_cost_base:				RUNNING_COST_DIESEL;						
		dual_headed:					0;												
		weight:							73 tons;
		ai_engine_rank:					0;
		engine_class:					ENGINE_CLASS_DIESEL;							
		tractive_effort_coefficient:	0.3
	}
	
	if(param_keep_old_vehs)
	{
		property
		{
			model_life:					VEHICLE_NEVER_EXPIRES;
		}
	}
	else
	{
		property
		{
			model_life:					37;
		}
	}
	
	graphics
	{
		purchase:						all_gp22u_purchase;
		default:						all_gp22u;
	}
	
}
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: [NML] Compiling error: Syntax error, unexpected token "}"

Post by Erato »

Have you tried putting the if statement inside of the property block without calling property again.

I think nml doesn't recognise that bracket as the end because there is no block called "if" and assumes you want to continue property.
No pics no clicks. Seriously.
ImageImageImageImageImageImage
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: [NML] Compiling error: Syntax error, unexpected token "}"

Post by Alberth »

PS: Line 55 is the "property" closing bracket, before the "if".
There is no semicolon on the line before.

EDIT: You are aware that there is also a "never_expire_vehicles" setting in the openttd.cfg file?



@Erato: The error is given before the line with the "if", so it cannot be that if-line.
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
Abydos
Engineer
Engineer
Posts: 20
Joined: 18 Dec 2016 01:51
Location: Rio de Janeiro, Brazil

Re: [NML] Compiling error: Syntax error, unexpected token "}"

Post by Abydos »

Well, guys, I got it sorted, but for this I had to pull out both if and else conditions.

Another problem I wanted to report is that some sprites I've done have some flashing pixels in shades of the same color in the game, and NMLC, at the end of a successful build, displays some warnings that "some pixels are animated". :|
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: [NML] Compiling error: Syntax error, unexpected token "}"

Post by Erato »

Abydos wrote:Well, guys, I got it sorted, but for this I had to pull out both if and else conditions.

Another problem I wanted to report is that some sprites I've done have some flashing pixels in shades of the same color in the game, and NMLC, at the end of a successful build, displays some warnings that "some pixels are animated". :|
Nice
Image
Here you see the colours and what they do. The colours in the cycles, as well as "fire" are animated and will always be animated. I often encounter a problem where the reddest red from the normal colours is also animated. Make sure to check where those pixels are and replace them with similar colours.
No pics no clicks. Seriously.
ImageImageImageImageImageImage
User avatar
Abydos
Engineer
Engineer
Posts: 20
Joined: 18 Dec 2016 01:51
Location: Rio de Janeiro, Brazil

Re: [NML] Compiling error: Syntax error, unexpected token "}"

Post by Abydos »

Here you see the colours and what they do. The colours in the cycles, as well as "fire" are animated and will always be animated. I often encounter a problem where the reddest red from the normal colours is also animated. Make sure to check where those pixels are and replace them with similar colours.
Ah yes, the sprites contained just a few pixels with these colors. Thanks!
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: No registered users and 38 guests