Page 1 of 1

MyAI says nothing to the console (OpenTTD11503NoAI)

Posted: 29 Nov 2007 21:17
by virusse
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:

Code: Select all

openttd -a "Virus AI" -g
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 :mrgreen:.

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();

Re: MyAI says nothing to the console (OpenTTD11503NoAI)

Posted: 29 Nov 2007 22:12
by Zuu
according to the lack of "./" in the beginning of your shell command I assume you are running windows. To get the output“from your print-statements you need to tell OpenTTD to open a debug window using the "-d" argument. So instead use:

Code: Select all

openttd -d -a "AI name" -g

I have not checked your squirrel code for mistakes as it might be correct, just that you have not opened the debug window yet.

Re: MyAI says nothing to the console (OpenTTD11503NoAI)

Posted: 30 Nov 2007 09:15
by virusse
*Slaps self silly* Thx. Like ever: The problem is infront of the monitor. :wink: