Page 1 of 1

Station near industry

Posted: 10 Oct 2011 15:57
by bri
Hello,

here is another question I have: I want to build a station near a industry, so that I can get and deliver goods. As I already know, the position of the Industry is the tile on the top right. But how can I find out the possible tiles I can build a station. From playing the game I know, that there is a maximum of 3 tiles beetween station and industry, so the station should be build at maximum 4 tiles away from the industry: So my fist idea was:
local area=AITileList();
area.AddRectangle(industry_tile-AIMap.GetTileIndex(4,4),industry_tile+AIMap.GetTileIndex(4,4));
But this doesn't concern the size of the industry. So there are two questions:

a) How can I find out the size of an industry?
b) Is the maximum distance between station and industrie alwaly 4 tiles or is there any function giving me this constant for my AI?

Re: Station near industry

Posted: 10 Oct 2011 16:04
by Yexo
a) You use AITileList_IndustryAccepting and AITileList_IndustryProducing
b) it depends on the station coverage radius.

Re: Station near industry

Posted: 10 Oct 2011 18:41
by Kogut
Small suggestion - you can download existing AIs and reuse code.

Re: Station near industry

Posted: 10 Oct 2011 19:44
by Zuu
Mind which license they use. All(?)/most AIs on BaNaNaS use some kind of open source license, but not all of them are compatible and thus it depends on which license you pick yourself, which AIs that you can copy code from.

Another option is to use libraries. In that case you don't have to copy the code but instead just include the library and thus don't have to care about license conflicts. For Road you find several useful functions in SuperLib. For Aircraft there is also some, but only for building stations near Towns (not industries). SuperLib also contains lots of functions for general problems not specific to any transport mode.