It adds console command debug_ai - first parameter is number of company, or "c" for current company, rest of the prameters are the debugging parameters.
The command will call Debug() method in the main AI class, passing rest of the parameters as specified on the commandline as strings.
for example,
Code: Select all
ai_debug 1 p1 blah
Code: Select all
Debug("p1","blah");
It also adds alias "ad", that will call "debug_ai c" and pass the rest of the parameters - intended usage of the alias is that you use cheat to switch to company you wish to debug and they you type just "ad" in console to save some keystrokes.
Some example of how the Debug() function may look like:
Code: Select all
function Debug(...) {
if (vargc<1) {
print("Need at least one parameter")
return;
}
print("Debug called");
for(local i = 0; i< vargc; i++) print("parameter "+i+" = "+vargv[i]);
}
Advantage is, that AI using these debug features can run even with unpatched OpenTTD without any modifications - you just won't be able to take advantage of calling the Debug() function...
Planned future improvements:
Print return value in console (so you can see response in the game console, which could be slightly more comfortable than having the AI debug console with the target AI opened)
So .... what are your oppinions about this patch?
Edit: update to newest trunk