Page 1 of 1

distance from edge

Posted: 25 Feb 2021 15:22
by Vanderbildt
Hello
is there any posibility to say Industry XY max distance to (map) edge?
there is a option in the settings: Maximum distance from edge for Oil industrys. It has a range from 12 to 128 tiles
but It won't work.

Thanks for help

Re: distance from edge

Posted: 25 Feb 2021 18:35
by jfs
There actually isn't any way to replicate that functionality in NewGRF, no. There is no way to request using one of the original check functions, the game setting isn't available to read from NewGRF, and industry callbacks don't have any way of getting distance from map edge.

However the game setting does work, just only for the built-in industries.

What you can do in NewGRF is check property 43 (in NML called water_distance) to test the distance from water/land, if you want to make coastal or non-coastal industries.

Re: distance from edge

Posted: 25 Feb 2021 19:13
by Eddi
well, you can sorta do this, by checking industry var 0x62 (or industrytile var 0x60) for tile type MP_VOID

Re: distance from edge

Posted: 25 Feb 2021 20:32
by Vanderbildt
hey jfs
However the game setting does work, just only for the built-in industries.
i try it with a vanilla 1.11 and i can place a refinery everwhere

and "build many random industrys" place the refinerys far away form the edge

so the game settings dosn't work.

i like to have the port etc on the coast not in the "lakes" but sea and lake water is the same.
property 43 check only the next land tile.

i hope that some day the edge function return to the game.

thanks for the answer

Re: distance from edge

Posted: 25 Feb 2021 22:17
by jfs
Check you don't have any NewGRF loaded that overrides the default industries, such as OpenGFX+.

It works perfectly well when I tested just now.
Version 20210225-master-gd4583fa64c067c (you probably won't find a binary of this exact version, it's my own build)
No NewGRF loaded.
512x512 map
Maximum distance from edge for Oil industries: 32 tiles

With this setup I can build oil refineries at the edge of the map, but not away from the edge.
Remember that oil wells don't have the restriction, they can be built anywhere. Only oil rigs and refineries have the restriction.

Re: distance from edge

Posted: 25 Feb 2021 23:06
by Vanderbildt
setting.JPG
setting.JPG (50.25 KiB) Viewed 2086 times
Unnamed, 08-01-2000.sav
(56.12 KiB) Downloaded 65 times
grf.JPG
grf.JPG (70.48 KiB) Viewed 731 times
there is no active GRF

Re: distance from edge

Posted: 26 Feb 2021 08:52
by jfs
Okay you left out one important detail: Scenario editor.

When in the scenario editor, apparently this setting is ignored. I'm not sure why, and that does seem like a bug.
During gameplay, the setting/restriction is fully functional.

Edit: No this restriction has been ignored (for oil refineries) in the scenario editor since the earliest available version of OpenTTD source code. You can test the same thing in version 0.4.5 of OpenTTD if you will, and find the same behaviour. It's not a bug, it's intentional that the restriction is ignored in the scenario editor.