OK, I'm going to release it. The code isn't commented (except a couple of variables at the top) so unless your TCL is good you're going to have to live with that if you want to modify it.
This is released under the
GNU General Public License and as such comes with no warranty. If your game runs all night with nobody on it, or you manage to lose a saved game you really liked, or it goes mental and locks up a server to which you have no physical access, all you are entitled to is my sympathy.
Right, you need Expect. This is a TCL extension and can be found here:
http://sourceforge.net/projects/expect
It works on Linux. I don't think I did anything platform specific, but you never know - it might also work on Windows or Mac or whatever.
Before you run it, change the motd variables at the start (or be embarrassed when somebody joins your server later). You can change the config file it uses here, or you can set the path to a valid openttd.cfg file in your OTTD_CONFIG environment variable - handy for multiple servers. You can also give a preferred net_frame_freq here. The script hopes that it (and you) are in the installed OpenTTD directory.
The script takes an optional parameter, which loads a saved game of the name "game.sav" from saves/. It can also take an additional optional parameter to load some other game.
./autopilot
./autopilot load
./autopilot load "save/Fundingford Transport.sav"
Windows people will need to either rename autopilot so that it has the extension that Expect expects, or they will need to run it like this:
expect autopilot
expect autopilot load
expect autopilot load "save/Fundingford Transport.sav"
Once you're running, the console might seem laggy. This is because it pays attention to the game for four seconds, then it pays attention to you for four seconds, then the game, etc. It doesn't miss stuff, though.
You have extra commands. The help command is extended, and if you type "save" without giving a filename it saves to game.sav in your save folder (which is the default for loading as mentioned above). Please note that the autopilot cannot be controlled by rcon! You need access to the dedicated console itself to use it. rcon will work as normal for all server functions.
The autopilot will greet people who join the game. It will unpause the server for them, and it will pause the game when they all leave. Once people have all left and the server is paused, it will save the game to save/game.sav, taking advantage of the fact that there's nobody to delay.
As people join and leave the game, autopilot will tell you how many people it thinks are connected. If this turns out to be wrong (autopilot has been known to miss the odd join or leave from time to time) then correct it from the console with the 'count' command, eg. 'count 2' will tell autopilot that there are two people connected, regardless of what it thought.
If anybody types "show autopilot version" into the in-game chat, it'll tell everybody the version. The console gives 'version' and 'license' commands, which pertain only to autopilot (although OpenTTD does use the same license, this is coincidental).
Finally, any commands you type into the console that autopilot doesn't recognise, it will relay to the game server.
If anybody has any questions, ask here. Despite what I said about there being no warranty, I'm happy to help out with modifications, etc.
Remember, autopilot is a wrapper. It is agnostic about the version of OpenTTD that it is being run on. As long as the console looks pretty much the same, it will work on any version.
(attachment moved to first post)