Page 51 of 65
Re: NML - a Newgrf Meta Language
Posted: 18 Oct 2015 11:39
by Alberth
The other way around, you need to state in the industry that you want to check the location.
Code: Select all
item(FEAT_INDUSTRIES, ....) {
...
graphics {
...
location_check: build_distance_check;
...
}
}
See
http://newgrf-specs.tt-wiki.net/wiki/NM ... _callbacks for a list of callbacks for industries
Re: NML - a Newgrf Meta Language
Posted: 18 Oct 2015 12:51
by GarryG
Not having any luck .. maybe it past my bedtime and a sleep will help. (Old bloke like me need his beauty sleep .. not that it helps much)
Am I suppose to use both
Code: Select all
" switch (FEAT_INDUSTRIES, SELF, freight_depot_build_distance_check, town_zone(0, 0)) { 5 .. 20: CB_RESULT_LOCATION_ALLOW; return CB_RESULT_LOCATION_DISALLOW; "
and
Code: Select all
" location_check: freight_depot_build_distance_check; "
I've had it work once but when test in a scenario to place the industry it say no suitable site found no matter how close or far I try to place it from the town.
Any other settings I've tried keeps coming up with ERROR messages.
Re: NML - a Newgrf Meta Language
Posted: 18 Oct 2015 13:08
by Transportman
That is because the return of town_zone is not 5..20, but something else, so your switch always disallows. The values to check for are listed
here.
If you want to check the actual distance to the town center, you should look at town_manhattan_dist and town_euclidean_dist.
Re: NML - a Newgrf Meta Language
Posted: 18 Oct 2015 13:18
by planetmaker
Transportman wrote:That is because the return of town_zone is not 5..20, but something else, so your switch always disallows. The values to check for are listed
here.
If you want to check the actual distance to the town center, you should look at town_manhattan_dist and town_euclidean_dist.
Oh indeed! Townzone has only very descrete values. The distance to the town centre is something different than town zone.
Re: NML - a Newgrf Meta Language
Posted: 18 Oct 2015 23:15
by GarryG
Thanks every one for trying to help me with this problem, but it just not clicking.
I tried what I think everyone means and what they say on the links to websites, but having no luck at all.
I get the message: is not referenced, ignoring.
I'm sorry to inconvenience you all.
I on a disability pension due to brain damage I suffered when I worked on the railways. I fell off the top of a wagon loaded with wool, fracturing my skull and breaking my ankles. It not easy for me these days to remember what I read and understand something's. Ask 3IFF he been helping me a lot with doing town names and started me with doing Industries. I've often asked him many questions to understand one answer. Old age might not be helping too .. wonder if I oldest person on these forums .. I turn 62 soon.
I wonder if I can send someone part of my NML file of the industry I trying to make it build near towns, but not too close.
The Industry Set I working on is great for those who want to use it when building their own scenarios. But not for those who like random made maps, as there are a few industried I made that designed to be close to towns.
This command: spec_flags: bitmask(IND_FLAG_BUILT_NEAR_TOWN); is ok for some, but it places Industry within 10 squares of the town centre. Like some of them to be a bit further away so they easier to build rail to without bulldozing houses.
Thanks again fellas for all the help.
Re: NML - a Newgrf Meta Language
Posted: 19 Oct 2015 01:06
by Eddi
GarryG wrote:I get the message: is not referenced, ignoring.
so, you defined a switch, but you did not use it in industry block to attach it to a callback.
Re: NML - a Newgrf Meta Language
Posted: 19 Oct 2015 01:49
by GarryG
Not sure if this what you mean. I been using the NML from FIRS 1.4.3 and SPI 1.1 to try learn somethings.
I copied this from the Grain Mill in FIRS 1.4.3 and changed the Industry names:
switch (FEAT_INDUSTRIES, SELF, freight_depot_town_distance, town_euclidean_dist(0, 0)) { 0 .. 30: return CB_RESULT_LOCATION_DISALLOW; }
switch (FEAT_INDUSTRIES, SELF, freight_depot_check_location, ( (extra_callback_info2 == IND_CREATION_FUND) || (extra_callback_info2 == IND_CREATION_PROSPECT) ) ) { 1: return CB_RESULT_LOCATION_ALLOW; freight_depot_town_distance; }
All lines it gives the same message "is not referenced, ignoring"
Are they the callbacks you mentioned?
Re: NML - a Newgrf Meta Language
Posted: 19 Oct 2015 05:22
by Transportman
Those are indeed the callbacks. As Alberth mentioned in an earlier
post, you need to add a line of code to the industry to make it work, a call to the switch freight_depot_check_location.
Re: NML - a Newgrf Meta Language
Posted: 19 Oct 2015 06:06
by GarryG
I tried what Alberth said and get the message "Unrecognized identifier".
I tried
Code: Select all
item(FEAT_INDUSTRIES, freight_depot, 62) {
graphics {
location_check: build_distance_check;
}
}
and also tried the line location_check: freight_depot_build_distance_check
If I put the line location_check: freight_depot_check_location .. it works but doesn't restrict the building of this industry with the radius I like from a town.
What I doing wrong this time?
Re: NML - a Newgrf Meta Language
Posted: 19 Oct 2015 10:32
by planetmaker
In your code, is the switch placed *above* the item declaration where the switch is referenced?
Re: NML - a Newgrf Meta Language
Posted: 19 Oct 2015 10:47
by 3iff
I've had a look at his code and think I've fixed it. The 'location_disallow' build bit was missing and the switch called didn't actually exist (a simple rename to the switch actually called was all it needed).
I decided to use the town_manhattan_dist call as it looks to give better results (well, results I think are better) but it's up to GarryG.
Re: NML - a Newgrf Meta Language
Posted: 19 Oct 2015 11:16
by GarryG
Thank you too all who have helped me.
What 3IFF has done for me works .. at least no more error messages.
When tested in Scenario Editor it still allows building the industry outside the limit I hoped 10 .. 30.
But now no errors< I can play around some more and see what I come up with.
Again thank you to all.
Re: NML - a Newgrf Meta Language
Posted: 19 Oct 2015 15:21
by Eddi
the scenario editor does not usually follow these restrictions, try in a game.
Re: NML - a Newgrf Meta Language
Posted: 19 Oct 2015 21:52
by GarryG
Hi all, finally got it working and it works it scenario editing too.
For those who interested the codes needed are:
Code: Select all
switch (FEAT_INDUSTRIES, SELF, freight_depot_town_distance, town_manhattan_dist(0, 0)) {
10 .. 20: return CB_RESULT_LOCATION_ALLOW;
return CB_RESULT_LOCATION_DISALLOW;
}
and
Code: Select all
item(FEAT_INDUSTRIES, freight_depot, 62) {
graphics {
location_check: freight_depot_town_distance;
}
}
freight_depot is the name of the industry. 10 .. 20 choses the closest and furthest distance from a town.
I think it a great code where can make a Industry either close to a town or further away depending on the type of industry.
Wish to offer my many thanks and appreciation to all who answered my plea to help me solve this problem. Thank you all so kindly.
Re: NML - a Newgrf Meta Language
Posted: 20 Oct 2015 06:34
by Wahazar
How to assign company colour to industry? I have png painted with 1cc blue colours, and switch
Code: Select all
switch (FEAT_INDUSTRIES, SELF, set_company_colour, founder_colour1)
{
2: return founder_colour2;
return founder_colour1;
}
//... in graphic section:
colour: set_company_colour;
but building is still blue...
Re: NML - a Newgrf Meta Language
Posted: 20 Oct 2015 07:03
by planetmaker
Do you have set to allow recolouring in the spritelayout?
Code: Select all
spritelayout building1 {
(...)
building {
(...)
recolour_mode: RECOLOUR_REMAP;
palette: PALETTE_USE_DEFAULT;
}
}
Re: NML - a Newgrf Meta Language
Posted: 20 Oct 2015 08:27
by Wahazar
Thanks, didn't know that it should be defined in spritelayout (I checked only industry tiles).
Re: NML - a Newgrf Meta Language
Posted: 20 Oct 2015 10:21
by planetmaker
McZapkie wrote:Thanks, didn't know that it should be defined in spritelayout (I checked only industry tiles).
Well, it's two things:
* you define at sprite level which sprites are subject to recolouring
* you define at industry level via the callback which colour shall be used as 'company colour' for those sprites subject to recolouring.
Re: NML - a Newgrf Meta Language
Posted: 20 Oct 2015 10:36
by Wahazar
If recolours are defined, and callback not, random colours would appears? I observed something like it.
Re: NML - a Newgrf Meta Language
Posted: 20 Oct 2015 10:41
by planetmaker
McZapkie wrote:If recolours are defined, and callback not, random colours would appears? I observed something like it.
Yes. From the callback
documentation: " Called after constructing the industry. The colour variable is set to a random value at this point, you can use this callback to change this. "