MyAI says nothing to the console (OpenTTD11503NoAI)
Posted: 29 Nov 2007 21:17
I've loaded OpenTTD nightly11503NoAI Win32 copied my main.nut the subdirectory. This is only a bittle playing around with these and that. So i looked over the tutorial in the wiki and over the writeai in ai subdirectory.
I started OpenTTD with the following line:
A game started and seven AI-Players joined, but its nothing to see in console. So where are my printings? Do i need to redirect a special AI console to the normal one or do some config work? I've tried to search for such a problem in forum, but that damn forum searchtool wants a three-character search key => "AI" is to short
.
main.nut
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();