I started OpenTTD with the following line:
Code: Select all
openttd -a "Virus AI" -g

main.nut
Code: Select all
//////////////////////////////////////////////////////////////////////
// //
// CLASS: VirusAI - the AI main class //
// //
//////////////////////////////////////////////////////////////////////
class VirusAI extends AIController {
stop = false;
function Start();
function Stop();
print("I am a very new AI with a ticker called VirusAI and I am at tick " + this.GetTick());
constructor()
{
}
}
function VirusAI::Start()
{
print("VirusAI::Start()");
this.Sleep(1);
if (!this.company.SetCompanyName("Virus AI")) {
local i = 2;
while (!this.company.SetCompanyName("VirusAI #" + i) {
i++;
}
}
while (!this.stop) {
print("I am a very new AI with a ticker called VirusAI and I am at tick " + this.GetTick());
this.Sleep(50);
}
}
function VirusAI::Stop()
{
print("VirusAI::Stop()");
this.stop = true;
}
//////////////////////////////////////////////////////////////////////
// //
// CLASS: FVirusAI - the factory class - registrating the ai //
// //
//////////////////////////////////////////////////////////////////////
class FVirusAI extends AIFactory {
function GetAuthor() { return "Stefan 'VirusSE' Ehrhardt"; }
function GetName() { return "Virus AI"; }
function GetDescription() { return "An example AI by following the tutorial at http://wiki.openttd.org/"; }
function GetVersion() { return 1; }
function GetDate() { return "2007-11-29"; }
function CreateInstance() { return "VirusAI"; }
}
/* Tell the core we are an AI */
iFVirusAI <- FVirusAI();