AI:AIInfo

From OpenTTD
Revision as of 13:00, 12 June 2008 by Mchl (Talk | contribs)

Jump to: navigation, search


info.nut is a file in which you tell NoAI basic things about your AI. It used to be part of main.nut, but it has been separated to make debugging easier (see here if you're interested in details).

info.nut structure

The internal structure of info.nut is very simple and follows a template presented below.

class MyNewAI extends AIInfo {
  function GetAuthor()      { return "Newbie AI Writer"; }
  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 "2007-03-17"; }
  function CreateInstance() { return "MyNewAI"; }
}

/* Tell the core we are an AI */
RegisterAI(MyNewAI());

Where of course you should change the names however you like to call everything. Just don't forget the RegisterAI(), and don't forget to extend AIInfo. If something goes wrong, check if you did: RegisterAI(MyNewAI()). Mind the () after MyNewAI!

Personal tools