BuildStation station_id?

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
User avatar
Kev!
Engineer
Engineer
Posts: 37
Joined: 21 Jun 2011 16:30
Location: In Da House!
Contact:

BuildStation station_id?

Post by Kev! »

Howdy,

Another noobtion ?( ...I am trying to build my first bus station and the call needs a station id? How do I know the station id if it hasn't been built yet? If i just put in a number like 1 it does not error out, but that can't be right...right?

I tried to look at some of your code but am not seeing it...

Please advise,
Kev!
I DO like a nice caboose...
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: BuildStation station_id?

Post by Zuu »

Please tell us what code you tried to use. Then we can give you advice without having to write an essay.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: BuildStation station_id?

Post by frosch »

The station ID is for distant-join, i.e. if you want to join the station with an existing one.
Use AIStation::STATION_NEW for a completely new station.
NoAI API docs wrote: station_id The station to join, AIStation::STATION_NEW or AIStation::STATION_JOIN_ADJACENT.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
Kev!
Engineer
Engineer
Posts: 37
Joined: 21 Jun 2011 16:30
Location: In Da House!
Contact:

Re: BuildStation station_id?

Post by Kev! »

Frosch,

Thank you for a short to the point response that actually answers my question! :bow: You have my eternal gratitude...


I will now try using AIStation::STATION_NEW in my BuildStation call.

I have a feeling I may need to get a loan before I can build anything?

Kev!
I DO like a nice caboose...
User avatar
Kev!
Engineer
Engineer
Posts: 37
Joined: 21 Jun 2011 16:30
Location: In Da House!
Contact:

Re: BuildStation station_id?

Post by Kev! »

Howdy,

Uh...just for the record...where exactly in the API documentation would I have found that?

AIStation::STATION_NEW

Annoying noobs want to know,
Kev!
I DO like a nice caboose...
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: BuildStation station_id?

Post by Brumi »

You can find it here, it is what frosch has quoted.

You don't need to take a loan first if the bus station is the only thing you build so far, check the error with

Code: Select all

AILog.Info(AIError.GetLastErrorString());
Do not forget to set the current road type first:

Code: Select all

AIRoad.SetCurrentRoadType(AIRoad.ROADTYPE_ROAD);
User avatar
Kev!
Engineer
Engineer
Posts: 37
Joined: 21 Jun 2011 16:30
Location: In Da House!
Contact:

Re: BuildStation station_id?

Post by Kev! »

Ha Ha! I just needed to Scroll down in AIRoad? I was gonna brag about finding it in the AIBaseStation section...I feel like a noob!

It's working! Thanks...

You are ALL awesome,
Kev!
I DO like a nice caboose...
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 33 guests