Page 1 of 1
API
Posted: 11 Feb 2012 12:20
by Bennievv
Does OpenTTD got an API?
Bennievv Newbie
Re: API
Posted: 11 Feb 2012 12:23
by Yexo
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.
Re: API
Posted: 15 Feb 2012 18:00
by Bennievv
For AI's

Re: API
Posted: 15 Feb 2012 18:04
by Bennievv
I found it:
http://wiki.openttd.org/Noai
EDIT Oops, I did say "API", but I needed a turtorial.

Error
Posted: 15 Feb 2012 18:34
by Bennievv
Uh... I have made a folder at OpenTTD/AI named "MyNewAI", with the
info.nut file:
Code: Select all
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: Select all
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
...I get the error:
Code: Select all
WARNING: Failed to load the specified AI
Re: API
Posted: 16 Feb 2012 12:13
by FooBar
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?
Re: API
Posted: 16 Feb 2012 13:01
by Bennievv
I maded it in OpenTTD/ai/MyNewAI, and I don't see it in the GUI-list...
But I gonna check it again...
Re: API
Posted: 16 Feb 2012 13:16
by Bennievv
Now it works!
Re: API
Posted: 28 Jan 2019 21:39
by rplus
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?
Re: API
Posted: 29 Jan 2019 01:01
by planetmaker
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.