MyAI says nothing to the console (OpenTTD11503NoAI)

Got a problem with OpenTTD? Find some help here.

Moderator: OpenTTD Developers

Post Reply
virusse
Engineer
Engineer
Posts: 6
Joined: 24 Oct 2006 17:09

MyAI says nothing to the console (OpenTTD11503NoAI)

Post 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();
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: MyAI says nothing to the console (OpenTTD11503NoAI)

Post 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.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
virusse
Engineer
Engineer
Posts: 6
Joined: 24 Oct 2006 17:09

Re: MyAI says nothing to the console (OpenTTD11503NoAI)

Post by virusse »

*Slaps self silly* Thx. Like ever: The problem is infront of the monitor. :wink:
Post Reply

Return to “OpenTTD Problems”

Who is online

Users browsing this forum: No registered users and 7 guests