Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sat Apr 20, 2019 5:20 pm

All times are UTC




Post new topic  Reply to topic  [ 10 posts ] 
Author Message
 Post subject: API
PostPosted: Sat Feb 11, 2012 12:20 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sat Feb 11, 2012 12:14 pm
Posts: 12
Location: The Netherlands
Does OpenTTD got an API?

Bennievv Newbie


Top
   
 Post subject: Re: API
PostPosted: Sat Feb 11, 2012 12:23 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
For what? Just read some basic in this forum or on the wiki. We have an API to write AIs and one to write GameScripts. I guess you could call the NewGRF specifications an API too.

Edit: and let's not forget the admin port.


Top
   
 Post subject: Re: API
PostPosted: Wed Feb 15, 2012 6:00 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sat Feb 11, 2012 12:14 pm
Posts: 12
Location: The Netherlands
For AI's :wink:


Top
   
 Post subject: Re: API
PostPosted: Wed Feb 15, 2012 6:04 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sat Feb 11, 2012 12:14 pm
Posts: 12
Location: The Netherlands
I found it:
http://wiki.openttd.org/Noai

EDIT Oops, I did say "API", but I needed a turtorial. :(


Last edited by Bennievv on Wed Feb 15, 2012 6:47 pm, edited 1 time in total.

Top
   
 Post subject: Error
PostPosted: Wed Feb 15, 2012 6:34 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sat Feb 11, 2012 12:14 pm
Posts: 12
Location: The Netherlands
Uh... I have made a folder at OpenTTD/AI named "MyNewAI", with the info.nut file:
Code:
class MyNewAI extends AIInfo {
  function GetAuthor()      { return "Bennievv"; }
  function GetName()        { return "MyNewAI"; }
  function GetDescription() { return "An example AI by following the tutorial at http://wiki.openttd.org/"; }
  function GetVersion()     { return 1; }
  function GetDate()        { return "2012-02-15"; }
  function CreateInstance() { return "MyNewAI"; }
  function GetShortName()   { return "XXXX"; }
  function GetAPIVersion()  { return "1.0"; }
}

RegisterAI(MyNewAI());


...and main.nut file:
Code:
class MyNewAI extends AIController 
{
  function Start();
}

function MyNewAI::Start()
{
  while (true) {
    AILog.Info("I am a very new AI with a ticker called MyNewAI and I am at tick " + this.GetTick());
    this.Sleep(50);
  }
}

...but if I type
Code:
start_ai MyNewAI

...I get the error:
Code:
WARNING: Failed to load the specified AI


Top
   
 Post subject: Re: API
PostPosted: Thu Feb 16, 2012 12:13 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 21, 2007 11:47 am
Posts: 6559
Location: The Netherlands
Do you have the AI files stored in the correct directory, so that OpenTTD can find them?
In other words: does you AI show up in the ingame (GUI) list?

_________________
FooBar's Tram Tracks | TransRapid Track Set | Metro Track Set | OpenGFX base graphics set | FIRS Industry Replacement Set
Dutch Tram Set | Dutch Trainset 2 | Dutch Road Furniture


Top
   
 Post subject: Re: API
PostPosted: Thu Feb 16, 2012 1:01 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sat Feb 11, 2012 12:14 pm
Posts: 12
Location: The Netherlands
I maded it in OpenTTD/ai/MyNewAI, and I don't see it in the GUI-list...
But I gonna check it again...


Top
   
 Post subject: Re: API
PostPosted: Thu Feb 16, 2012 1:16 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sat Feb 11, 2012 12:14 pm
Posts: 12
Location: The Netherlands
Now it works!


Top
   
 Post subject: Re: API
PostPosted: Mon Jan 28, 2019 9:39 pm 
Offline
Engineer
Engineer

Joined: Mon Aug 19, 2013 1:08 pm
Posts: 3
Location: Wrocław, Poland
Hi,

I've got the same issue.

Tried in C:\Program Files\OpenTTD\ai\MyNewAI\ and C:\Users\<user_name>\Documents\OpenTTD\ai\MyNewAI\ on Windows 10.

My AI does not show up in list_ai results.

Any hints?


Top
   
 Post subject: Re: API
PostPosted: Tue Jan 29, 2019 1:01 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9260
Location: Sol d
My best bet is "some of the necessary info is missing". Hard to tell.

Call OpenTTD in debug mode to check:

You can test the detected AI and libraries by calling "openttd --help" in the command line. And possibly by calling it in debug mode: "openttd -d script=X" where X is a number 1...9. The higher the more spammy it will get.

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2019 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2019.
Hosted by Zernebok Hosting.