Page 3 of 3

Re: Szurke NML Questions???

Posted: 01 Jun 2015 08:34
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.

Re: Szurke NML Questions???

Posted: 03 Jul 2015 09:44
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.

Re: Szurke NML Questions???

Posted: 03 Jul 2015 10:17
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

Re: Szurke NML Questions???

Posted: 10 Mar 2017 17:29
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!

Re: Szurke NML Questions???

Posted: 12 Mar 2017 13:02
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?

Re: Szurke NML Questions???

Posted: 14 Mar 2017 22:06
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

Re: Szurke NML Questions???

Posted: 15 Mar 2017 22:45
by Szurke
Then how can a swith return with an integer or float?

Re: Szurke NML Questions???

Posted: 18 Mar 2017 23:15
by Eddi
switches can never return floats, only integers. (or sprites, other switches)

Re: Szurke NML Questions???

Posted: 19 Mar 2017 17:41
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.

Re: Szurke NML Questions???

Posted: 01 Apr 2017 15:21
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!

Re: Szurke NML Questions???

Posted: 01 Apr 2017 17:25
by Transportman
When are you calling that switch? In the code you show it is not called and thus not doing anything.

Re: Szurke NML Questions???

Posted: 02 Apr 2017 09:40
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.

Re: Szurke NML Questions???

Posted: 06 Apr 2017 21:52
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;
}

Re: Szurke NML Questions???

Posted: 07 Apr 2017 12:30
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"

Re: Szurke NML Questions???

Posted: 16 Apr 2017 12:55
by Szurke
Eddi, i have your option too tryd, but don't work.

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

Re: Szurke NML Questions???

Posted: 10 Jan 2020 12:24
by Szurke
Hi guys!

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

Re: Szurke NML Questions???

Posted: 10 Jan 2020 13:10
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! :)

Re: Szurke NML Questions???

Posted: 14 Mar 2022 23:32
by Szurke
Hi guys again! :)

I tried it again an industry make, what can build nearbery an another indurstry.

To that, i want use be the

Code: Select all

nearby_tile_industrytile_id
but i can't make an workably version. (Yes the same problem like before).
Maybe it's can't use to another Industry, or i have make some wrong?


Code: Select all

item(FEAT_INDUSTRYTILES, title_00_ISZAN_1, 0x00) 
{
	property 
	{
		substitute: 0x00;
		override:	0x00;
		accepted_cargos: [[PASS, 8], [FERT, 8], [MNSP, 8]];
	}
	graphics {	layout_00_ISZAN;	}
}
tilelayout titlelayout_ISZAN_0
{
	0, 0: title_00_ISZAN_0;
}


switch(FEAT_INDUSTRYTILES, SELF, nearby_tile_industrie,
	nearby_tile_industrytile_id (0,1))
{ 	
	0x0000..0xFFFE:	return CB_RESULT_LOCATION_ALLOW	;
	CB_RESULT_LOCATION_DISALLOW;
}

item(FEAT_INDUSTRYTILES, title_00_IGYAR) {
	property {
		substitute: 0x1B;
		accepted_cargos: [];
	}
	graphics {
		tile_check:	nearby_tile_industrie;
		layout_00_ISZAN;
	}
}
item(FEAT_INDUSTRIES, ISZAN, 0x00) 
{
	property 
	{
		substitute: 					0x00;
		override:						0x00;
		name:                           string(STR_NAME_ISZAN);
		layouts:                        [titlelayout_ISZAN_0];
		prob_random:                    64;
		prob_in_game:                   2;
		cargo_types:					[	accept_cargo("FERT"), accept_cargo("MNSP"),
											produce_cargo("GRAI", 0), produce_cargo("WSTE", 0)	];
		map_colour:                     0xC2;
		life_type:                      IND_LIFE_TYPE_PROCESSING;
		fund_cost_multiplier:           100;
		min_cargo_distr:                0;
		prospect_chance:                0.75;
		spec_flags:						bitmask(IND_FLAG_PLANT_FIELDS_PERIODICALLY);
	}
}
item(FEAT_INDUSTRIES, ISZAN, 0x00) 
	{
		graphics 
		{
			build_prod_change:			Industry_reset_switch;
			stop_accept_cargo:			ISZAN_worker_acceptance;
			//extra_text_industry:		IUJRA_extra_text;
			produce_256_ticks:			ISZAN_termes;
			control_special:			ISZAN_control;
		}
	}
	
- - - - - -

tilelayout titlelayout_IGYAR {
	0, 0:	title_00_IGYAR;
}


switch(FEAT_INDUSTRIES, SELF, IGYAR_extra_text_00, current_year)
{
	return	string(STR_IND_GYAR); 
}


item(FEAT_INDUSTRIES, IGYAR, 0x1B) {
	property {
		substitute: 					0x1B;
		name:                           string(STR_NAME_IGYAR);
		layouts:                        [titlelayout_IGYAR];
		prob_random:                    0;
		prob_in_game:                   100;
		accept_cargo_types:             [];
		prod_cargo_types:               [];
		map_colour:                     0x11;
		life_type:                      IND_LIFE_TYPE_PROCESSING;
		//spec_flags:						bitmask(IND_FLAG_BUILT_ONLY_BEFORE_1950);
		fund_cost_multiplier:           100;
		prod_multiplier:                [0, 0];
		min_cargo_distr:                0;
		input_multiplier_1:             [0, 0];
		input_multiplier_2:             [0, 0];
		input_multiplier_3:             [0, 0];
		prospect_chance:                10;
//		spec_flags:						bitmask(IND_FLAG_ONLY_IN_TOWNS);
	}
	graphics
	{
		build_prod_change:			Industry_reset_switch;
		//stop_accept_cargo:			IGYAR_worker_acceptance;
		extra_text_industry:		IGYAR_extra_text_00;
		//produce_256_ticks:			IGYAR__prod;
	}
}