How to make: industry can only be built on specific spot
Moderator: Graphics Moderators
How to make: industry can only be built on specific spot
After looking at the confusion of Var-action 2 specifications I would like to know what's the easiest way to make:
-Oil Refinery can only be built so many squares near the water
-Farm can only be built under the snow-line
-Forest can only be built over the snow-line and so forth.
Can it be a simple Action 0 or a confusing Action 2 (a version of it)?
Please write me some commented examples if you will, because there aren't any in the GRF-specs.
-Oil Refinery can only be built so many squares near the water
-Farm can only be built under the snow-line
-Forest can only be built over the snow-line and so forth.
Can it be a simple Action 0 or a confusing Action 2 (a version of it)?
Please write me some commented examples if you will, because there aren't any in the GRF-specs.
NewGRF: Oil Wells in Temperate terrain now can Increase production, Better vehicle names, Use-able default aircraft, Oil Rig for Snowland and Desert, Speed for Suspension bridges.
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
Re: How to make: industry can only be built on specific spot
What about farms when there is variable snow line grf activated?SirkoZ wrote:-Farm can only be built under the snow-line
TT-Screenshot Of The Month - 2012 July, winner!
TT-Screenshot Of The Month - 2013 May, winner tie with Purno!
TT-Screenshot Of The Month - 2014 February, winner!
TT-Screenshot Of The Month - 2014 June, winner tie with alluke!
TT-Screenshot Of The Month - 2014 April, winner!
My screen shot thread ---> Have a look
TT-Screenshot Of The Month - 2013 May, winner tie with Purno!
TT-Screenshot Of The Month - 2014 February, winner!
TT-Screenshot Of The Month - 2014 June, winner tie with alluke!
TT-Screenshot Of The Month - 2014 April, winner!
My screen shot thread ---> Have a look
Re: How to make: industry can only be built on specific spot
You will need callback 0x28 for that.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)?
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-Oil Refinery can only be built so many squares near the water
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.-Farm can only be built under the snow-line
-Forest can only be built over the snow-line and so forth.
Checking the summer snowline (as OTTD does for both) is not possible for newgrfs.
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 youPlease write me some commented examples if you will, because there aren't any in the GRF-specs.

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.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
- andythenorth
- Tycoon
- Posts: 5705
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: How to make: industry can only be built on specific spot
This isn't exactly what you need (there's loads of stuff going on in this short nfo). It is reasonably commented, and it *does* use CB 28 to determine whether the 'catfood mine' industry can be built. In my case, it's checking for another industry nearby. You'll need to check a different variable. It also checks loads of other things in CBs 
If I recall correctly, my code may also give the player some feedback via 'error' strings, which you might find useful. I wrote this at christmas though and haven't looked at it since! It has two industries in it by the way.
This code also includes the production callback you'll need to terminate the varaction 2 chain. Weirded me out the first time I saw it - I was used to coding vehicles.
(EDIT) Looks like Frosch has indicated which variables you'll need to check.
cheers,
Andy

If I recall correctly, my code may also give the player some feedback via 'error' strings, which you might find useful. I wrote this at christmas though and haven't looked at it since! It has two industries in it by the way.
This code also includes the production callback you'll need to terminate the varaction 2 chain. Weirded me out the first time I saw it - I was used to coding vehicles.
(EDIT) Looks like Frosch has indicated which variables you'll need to check.
cheers,
Andy
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Re: How to make: industry can only be built on specific spot
That's a very good question, however at this time I don't have any good solution to that problem.ISA wrote:What about farms when there is variable snow line grf activated?SirkoZ wrote:-Farm can only be built under the snow-line
__________________________________________________________________________________
Thank you very much to both of you, Frosch and Andythenorth.
I hoped it could be solved by a simple action 0, but with your pointers Frosch and Andythenorth's example .nfo I should be able to solve this one. A doozy indeed.

NewGRF: Oil Wells in Temperate terrain now can Increase production, Better vehicle names, Use-able default aircraft, Oil Rig for Snowland and Desert, Speed for Suspension bridges.
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
- andythenorth
- Tycoon
- Posts: 5705
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: How to make: industry can only be built on specific spot
PBI farms stop producing for the winter (i.e when they are above the snowline). That's one option.SirkoZ wrote:That's a very good question, however at this time I don't have any good solution to that problem.
(EDIT), actually, I'm not sure, it might be Alpine Climate that caused that to happen in a game where I was also using PBI.
cheers,
Andy
Last edited by andythenorth on 21 Apr 2009 06:43, edited 1 time in total.
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Re: How to make: industry can only be built on specific spot
They do?andythenorth wrote:PBI farms stop producing for the winter (i.e when they are above the snowline). That's one option.SirkoZ wrote:That's a very good question, however at this time I don't have any good solution to that problem.
cheers,
Andy
Haven't seen that! That would be solution!
TT-Screenshot Of The Month - 2012 July, winner!
TT-Screenshot Of The Month - 2013 May, winner tie with Purno!
TT-Screenshot Of The Month - 2014 February, winner!
TT-Screenshot Of The Month - 2014 June, winner tie with alluke!
TT-Screenshot Of The Month - 2014 April, winner!
My screen shot thread ---> Have a look
TT-Screenshot Of The Month - 2013 May, winner tie with Purno!
TT-Screenshot Of The Month - 2014 February, winner!
TT-Screenshot Of The Month - 2014 June, winner tie with alluke!
TT-Screenshot Of The Month - 2014 April, winner!
My screen shot thread ---> Have a look
Re: How to make: industry can only be built on specific spot
the alpine farms do it like that, too.
- andythenorth
- Tycoon
- Posts: 5705
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: How to make: industry can only be built on specific spot
Eddi wrote:the alpine farms do it like that, too.

FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Who is online
Users browsing this forum: No registered users and 4 guests