Szurke NML Questions???

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

Moderator: Graphics Moderators

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9415
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Szurke NML Questions???

Post by planetmaker »

SaltMacaroni wrote:The full code is 3 post before this.

The new NML is good, create GRF, but the GRF isnt workink good.

My plan is: the vehicle has got company_colour1 and one random color insted of company_color2.
OpenGFX+Trains does a simplified version of that, where a random colour is applied to the containers of the flatbed wagons (ignoring company colour):
https://hg.openttdcoop.org/ogfx-trains/ ... .pnml#L132

you'll need to check the current company colour and return a 2CC palette based on that result, if you want a random 2CC but the fixed 1st CC.

Szurke
Engineer
Engineer
Posts: 22
Joined: 28 Aug 2014 10:56

Re: Szurke NML Questions???

Post by Szurke »

Hi guys!

I have a new question: How can i check tath, a user use an other grf?

Btw: i make an Industry, and i wanna the groundtile modifying, when use the CHIPS set to.

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9415
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Szurke NML Questions???

Post by planetmaker »

Szurke wrote:Hi guys!

I have a new question: How can i check tath, a user use an other grf?

Btw: i make an Industry, and i wanna the groundtile modifying, when use the CHIPS set to.
There's grf_future_status and possibly interesting grf_order_behind (there usually is no need to check for grf_current_status). See http://newgrf-specs.tt-wiki.net/wiki/NM ... _functions and check e.g. OpenGFX+Trains for examples

Szurke
Engineer
Engineer
Posts: 22
Joined: 28 Aug 2014 10:56

Re: Szurke NML Questions???

Post by Szurke »

Hy guys!

It me again! Long time ago have we us did't to see! =)

So the new question is: I wanna be limit an accepted cargo type in Industrie.
I can set a max limit by IndustryTitle, but i can't rally stop the accepting, when it is over tht limit.

I can stoping all cargi incame, but i wanna only on of accapting cargotype.

Thans the answers again!

Szurke
Engineer
Engineer
Posts: 22
Joined: 28 Aug 2014 10:56

Re: Szurke NML Questions???

Post by Szurke »

Ok, i have ansver my question! XD

Code: Select all


switch(FEAT_INDUSTRIES, SELF, IUJRA_worker_stopp, extra_callback_info2 & 0xFF)	
{	
 PASS : 	return 0;				//stop accept PASS
 default :	return 1; 	
}	

switch(FEAT_INDUSTRIES, SELF, IUJRA_worker_acceptance, 
(waiting_cargo_2 >= 200)) {		//<- Ther is the rally check of limit
	1: return	IUJRA_worker_stopp;
	return	1;
}

switch(FEAT_INDUSTRIES, SELF, IUJRA_munkas, 
(waiting_cargo_2)){
	0 : 		IUJRA_production_wait;
	1..9:		IUJRA_prod_slow;
	10..49:	IUJRA_prod_norm;
	50..99:	IUJRA_prod_full;
	return	IUJRA_prod_max;
}
	
item(FEAT_INDUSTRIES, IUJRA) {
	property {
		substitute: 			0;
		name:				string(STR_NAME_IUJRA);
		layouts:				[titlelayout_IUJRA,titlelayout_IUJRA2];
		prob_random:			5;
		prob_in_game:			2;
		accept_cargo_types:           [GRAB, PASS];
		map_colour:                     	0xB6;
		life_type:                      	IND_LIFE_TYPE_PROCESSING;
		spec_flags:			bitmask(IND_FLAG_BUILT_ONLY_AFTER_1960);
		fund_cost_multiplier:          100;
		prod_multiplier:                	[0, 0];
		min_cargo_distr:                5;
		input_multiplier_1:             [0, 0];
		input_multiplier_2:             [0, 0];
		input_multiplier_3:             [0, 0];
		prospect_chance:          	0.75;
	}
	graphics {
		build_prod_change:		IUJRA_reset_switch;
		cargo_output	:		IUJRA_cargo_production;	
		stop_accept_cargo:		IUJRA_worker_acceptance;	// <- There is the check of limit
		extra_text_industry:		IUJRA_extra_text;
		produce_256_ticks: 		IUJRA_munkas;
	}
}
And thanks for ECS, becouse i have there fund the code, what i had need.


Another question: How can i declarate an constans, or global variable for btw a limit?

Eddi
Tycoon
Tycoon
Posts: 7479
Joined: 17 Jan 2007 00:14

Re: Szurke NML Questions???

Post by Eddi »

NML does not have constants.
you can write "variable = <value>" but that uses up one of the global variable slots ("parameters"), which are fairly limited

you can, however, use programs like the C Preprocessor (cpp) to evaluate constants for you:
  • write a .pnml file using "#define CONSTANT <value>"
  • run cpp on your .pnml file to generate the .nml file
  • run nmlc on your .nml file
You might not exactly be interested in Ferion, but if you are, have fun :)

Szurke
Engineer
Engineer
Posts: 22
Joined: 28 Aug 2014 10:56

Re: Szurke NML Questions???

Post by Szurke »

Then how can a swith return with an integer or float?

Eddi
Tycoon
Tycoon
Posts: 7479
Joined: 17 Jan 2007 00:14

Re: Szurke NML Questions???

Post by Eddi »

switches can never return floats, only integers. (or sprites, other switches)
You might not exactly be interested in Ferion, but if you are, have fun :)

Szurke
Engineer
Engineer
Posts: 22
Joined: 28 Aug 2014 10:56

Re: Szurke NML Questions???

Post by Szurke »

Thanks of lot of answers!

But i have more question:

I wanna be check an nearby title, there is that industrie, what i need? So did't any industry, just that one, what i need.

Szurke
Engineer
Engineer
Posts: 22
Joined: 28 Aug 2014 10:56

Re: Szurke NML Questions???

Post by Szurke »

Hi again!

I found nearby_tile_industrytile_id with maybe can i the nearby industry checking. But i don't know how it work!

I just try this:

Code: Select all

item(FEAT_INDUSTRYTILES, title_15)
{
	property 
	{
		substitute:			0x20;
		override:			0x20;
		accepted_cargos:	[[COAL, 8], [IORE, 8]];
		land_shape_flags:	bitmask(LSF_ONLY_ON_FLAT_LAND);
	}
	graphics
	{
		random_title_IUJRA;
	}
}

Code: Select all

switch(FEAT_INDUSTRYTILES, SELF, tile_check,
	nearby_tile_industrytile_id (0,1))
{ 	
	0x0020:	return CB_RESULT_LOCATION_ALLOW	;
	CB_RESULT_LOCATION_DISALLOW;
}
But it don't work.

Please Help!

Transportman
Tycoon
Tycoon
Posts: 2743
Joined: 22 Feb 2011 18:34

Re: Szurke NML Questions???

Post by Transportman »

When are you calling that switch? In the code you show it is not called and thus not doing anything.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML

Szurke
Engineer
Engineer
Posts: 22
Joined: 28 Aug 2014 10:56

Re: Szurke NML Questions???

Post by Szurke »

Sorry, that i have forgott.

Code: Select all

item(FEAT_INDUSTRYTILES, title_00_ITAROL) {
	property {
		substitute: 0x1F;
		accepted_cargos: [];
		land_shape_flags: bitmask(LSF_ONLY_ON_FLAT_LAND);
	}
	graphics {
		tile_check:  tile_check;
		random_title_IUJRA;
	}
}
But i think, don't that the problem is.

Eddi
Tycoon
Tycoon
Posts: 7479
Joined: 17 Jan 2007 00:14

Re: Szurke NML Questions???

Post by Eddi »

just a random thought (i don't actually know how industrytiles work):

Code: Select all

item(FEAT_INDUSTRYTILES, title_15, <put some number here>)

Code: Select all

switch(FEAT_INDUSTRYTILES, SELF, tile_check,
	nearby_tile_industrytile_id (0,1))
{ 	
	<put same number here>:	return CB_RESULT_LOCATION_ALLOW	;
	CB_RESULT_LOCATION_DISALLOW;
}
You might not exactly be interested in Ferion, but if you are, have fun :)

Szurke
Engineer
Engineer
Posts: 22
Joined: 28 Aug 2014 10:56

Re: Szurke NML Questions???

Post by Szurke »

Thansk Eddi, i have too try that, but didn't work.

Its come back with error:
"Item parameter 2 'name' should be an identifiter"

Szurke
Engineer
Engineer
Posts: 22
Joined: 28 Aug 2014 10:56

Re: Szurke NML Questions???

Post by Szurke »

Eddi, i have your option too tryd, but don't work.

Just overrid som pictur. So it make only caos in grafik.

Szurke
Engineer
Engineer
Posts: 22
Joined: 28 Aug 2014 10:56

Re: Szurke NML Questions???

Post by Szurke »

Hi guys!

Why not support in the lest half year the NML versions to Windows?

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9415
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Szurke NML Questions???

Post by planetmaker »

It's Python, so it also works on windows as-is when not compiled into an executable, you just need to install python and then install the nml module and you can run that just fine.
Please see the NML topic, it has an answer to your question and how to resolve it: viewtopic.php?p=1228014#p1228014

As to the reason why there is no exe right now: the compilation to exe did not survive the upgrade to python 3.5 which now is necessary - and as the build infrastructure is being re-vamped it didn't seem worthwhile to invest loads of time in an old procedure which better is done in the new (which unfortunately does not yet produce exes either). Anyone want to do that with GitHub actions? Clone the repo and make a PR to make it possible, please! :)

Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: JGR and 2 guests