SirkoZ wrote:After looking at the confusion of Var-action 2 specifications I would like to know what's the easiest way to make:
(...)
Can it be a simple Action 0 or a confusing Action 2 (a version of it)?
You will need callback 0x28 for that.
-Oil Refinery can only be built so many squares near the water
Check industry variable 8B (Distance to the closest water tile if property 1A bit 2 is clear (built on land); distance to the closest empty dry land tile if property 1A bit 2 is clear (built on water)) in callback 28 (*) and compare it to the wanted value
-Farm can only be built under the snow-line
-Forest can only be built over the snow-line and so forth.
Check variable 87 (Ground type of the selected spot (see canal variable 81 for details) in callback 28 (*). It tells you whether the north tile of the industry is currently on/above the snowline.
Checking the summer snowline (as OTTD does for both) is not possible for newgrfs.
Please write me some commented examples if you will, because there aren't any in the GRF-specs.
If you get the basics of varaction2 you can use grf2html to take a look at other newgrfs. But do not do that in the beginning, as you would likely choose a very advanced newgrf, which might frighten you
However you need (in reversed order):
1) Action 3
2) VarAction2: check word variable 0C "current callback"
2a) If variable is 0x28: Chain to 4)
2b) Else: chain to 10)
3) VarAction2: Check the snow/water stuff
3a) If acceptable: return 0x400 (resp. 0x8400; 0x8000 is actually the return)
3b) If not acceptable: return 0x401 resp. 0x8401
4) Action2 Production callback: If you do not need production callbacks, just put here some arbitrary values (like producing 0 out of 0). It is just needed to terminate the chain with a callback-failed.
Note that these actions have to appear in the grf in reversed order, i.e. 4) first, 1) last.
You also have to activate callback 28 in action0 industry property 21 (Callback flags)
(*) Note: These are special variables only available during callback 28, as the normal variables are not available until the industry is built.