Page 1 of 3
AI crashing
Posted: 14 Feb 2012 01:20
by trotter94
Hi,
I am trying to create my own ai but i keep getting an error, even with just the minimum code:
Code: Select all
class trAI extends AIController
{
constructor() {
}
}
function trAI::Start()
{
AILog.Info("Starting")
while (true) {
}
}
- error.png
- /w code above
- (301.37 KiB) Downloaded 2 times
I've tried import the library and also i tried re-installing openttd.
Re: AI crashing
Posted: 14 Feb 2012 05:52
by Yexo
That error message does not match your code. Please provide the exact code you're trying to use.
Re: AI crashing
Posted: 14 Feb 2012 13:31
by trotter94
It is the exact code (+ info.nut).
It comes up with exact same error message (including same line) whatever code i use.
I've checked that the files are in the right place.
I don't get what Pathfinder.Road has got to do with anything? I wasn't trying to use it at first.
Re: AI crashing
Posted: 14 Feb 2012 14:18
by Lord Aro
trotter94 wrote:I don't get what Pathfinder.Road has got to do with anything? I wasn't trying to use it at first.
Hence why it is thought that you didn't post the same code
Where are you putting the code currently?
Re: AI crashing
Posted: 14 Feb 2012 16:10
by trotter94
Code: Select all
C:UsersThomasDocumentsOpenTTDcontent_downloadaitrAI
Edit: forum doesn't seem to like backslash.
Re: AI crashing
Posted: 14 Feb 2012 17:37
by Lord Aro
check in the installation directory of OTTD, it might be hidden somewhere
(see section 4.2 of readme.txt about where things might be located)
Re: AI crashing
Posted: 14 Feb 2012 17:49
by Zuu
Put your ai in C:\Users\Thomas\Documents\OpenTTD\aitrAI (don't put your development files in content_download)
You could try to change the short + long name of your AI in info.nut to something that you are sure is unique to make sure that OpenTTD uses your code and not some other AI code.
Re: AI crashing
Posted: 14 Feb 2012 17:50
by Yexo
Perhaps your shortname clashes with Trans AI?
Re: AI crashing
Posted: 14 Feb 2012 19:14
by trotter94
I haven't downloaded any ai after i re-installed openttd (i have 1 now, ChooChoo.).
I have moved the ai to where zuu said and changed the names, however it still doesn't work and still says trAI in the ai menu (should be long name "TrotterAI" and short name "tAI").
Re: AI crashing
Posted: 14 Feb 2012 19:35
by trotter94
I found a trAI folder in the program files ai folder, i don't remember putting it there and i re-installed openttd a few days ago.
I deleted that one but TrotterAI doesn't appear in openttd.
Re: AI crashing
Posted: 14 Feb 2012 20:09
by Zuu
If it doesn't appear, you probably have a syntax error in your code that is fatal enough that your AI don't show up in the list.
Start OpenTTD with -d to get the start up messages where you'll see which AIs that fail to compile.
Re: AI crashing
Posted: 14 Feb 2012 20:41
by MinchinWeb
I'm pretty sure short names have to be exactly 4 characters long. In your
info.nut, try using this line (or something like it) instead:
Code: Select all
function GetShortName() { return "tAI_"; }
Re: AI crashing
Posted: 14 Feb 2012 21:25
by trotter94
It works if I put it back in the content_download ai folder.
and yes i think it has be 4 letters.
Re: AI crashing
Posted: 14 Feb 2012 21:38
by Lord Aro
Zuu wrote:(don't put your development files in content_download)

Re: AI crashing
Posted: 14 Feb 2012 21:54
by trotter94
Lord Aro wrote:Zuu wrote:(don't put your development files in content_download)

Well where am i meant to put them!?
Re: AI crashing
Posted: 14 Feb 2012 23:46
by Zuu
In C:\Users\Thomas\Documents\OpenTTD\ai\trAI
(sorry, I forgot to add one slash above in my previous post when fighting against the slash remover in the forum)
or in the "ai" directory of your OpenTTD installation that you use for AI development. (if you want to keep your development AIs way from your other installations of OpenTTD)
Re: AI crashing
Posted: 17 Feb 2012 02:03
by trotter94
How do you include the standard math library?
Re: AI crashing
Posted: 17 Feb 2012 05:14
by MinchinWeb
We don't have a "standard math library"... The most common Libraries are listed on Bananas (
here) which hosts the files for the in-game download system. Once you have the library you want, add a line like this near the top of your
main.nut:
Code: Select all
import("util.MinchinWeb"' "MinchinWeb"' 4)
The first parameter is the library's category and name, the next is what you want the library's main class to be called in your program, and the third parameter is the version of the library you are importing.
Re: AI crashing
Posted: 17 Feb 2012 11:49
by trotter94
Does't squirrel have it's own math library?
Re: AI crashing
Posted: 17 Feb 2012 14:48
by Lord Aro
Depends what you want
However, you don't need to include anything other than downloaded libraries