Help with batch script

Ethelred

Member
I've seem to be having trouble getting around to running all my chars every day recently and would like to create a batch script to run right after rollover to handle daily essential actions. For characters in a run, this would probably be nothing, but I usually have several chars in aftercore who farm mushrooms and that can get out of phase if a day is missed. I play on a Mac and my normal routine is to double-click the KoLmafia .jar file, log in a character, open a browser window, then run my turns for the day. If in run, that's mostly clicking in the browser window and occasionaly running a script. In aftercore, it's mostly running scripts with an occasional action in the browser window. When done, I logout, close the browser window, and quit mafia. Often I repeat that process for another character.

I see that ASH has login and logout commands, but don't really understand how to use them. So I'm looking for some more detailed documentation, or, better yet, and example of the batch script to run several chars, and a sample of the ASH script necessay to run one instance of mafia.

Thanks, in advance, for any links to examples or sample code.
 

MCroft

Developer
Staff member
So, you can make a simple ASH script to call cli commands to do your stuff, including running other scripts. There are more complex ways to do it, but here's a really basic script that may get you started.

It's a list of CLI commands to execute.
PHP:
void main()
{
    cli_execute("login BadHorseMonkey");
    cli_execute("inv");
    cli_execute("login Mad Carew");
    cli_execute("quit");
}
You save that to your ~/Library/Application\ Support/KoLmafia/scripts folder with a name like MadCarewSwitchUser.ash

And you invoke it from the Terminal with a command like: java -jar KoLmafia-27543-M.jar --CLI MadCarewSwitchUser

There are lots of optimizations:
1: you could write ash scripting commands instead of a set of CLI commands.
2: you could use Automator on the desktop to give you a button to click to run the script.
3: you could set up a login script for your various users to do what you wanted them to do when you started up.

But getting started is just a few steps. login BHM, run autoscend, login Mad, run Garbo, login AelitaQueenOfMars, run VMF...

Let me know if that helps!
 
Top