I was looking into an issue with VMF. That script will collect semirares for you (if configured to do so). It will also bust ghosts and fight vote monsters. All of those are on their own schedules, so when consuming adventures, it will break out to perform the designated actions and then continue. Which is to say, it essentially has a counter script built in.
However, the script will also call other scripts to consume turns (if configured). In particular, Gingerbread City and Spacegate. Since neither of those will collect semirares, if your counter expires while running them, they proceed and you lose it.
I'm considering making a custom counterScript, integrated with VMF, which will be active while running external scripts. Looking at how KoLmafia invokes a counterScript:
The property "counterScript" contains the name of an ASH file.
When a counter expires, that script is invoked via
boolean main( string name, int remaining );
In the context of my scripts, which only go places that take a single adventure at a time, remaining will always be 0, and the semirare (whatever) will occur on the very next adventure.
VMF contains a function:
void main()
This is the method which is invoked if you simply execute the script. I wonder if I could overload it and have
boolean main( string name, int remaining )
and simply set VMF as its own counterScript while it is executing, and thereby having access to all its own internal state? Intriguing!
However, the script will also call other scripts to consume turns (if configured). In particular, Gingerbread City and Spacegate. Since neither of those will collect semirares, if your counter expires while running them, they proceed and you lose it.
I'm considering making a custom counterScript, integrated with VMF, which will be active while running external scripts. Looking at how KoLmafia invokes a counterScript:
Code:
KoLmafiaASH.logScriptExecution( "Starting counter script: ", scriptFile.getName(), interpreter );
Value v = interpreter.execute( "main", new String[]
{
expired.getLabel(),
String.valueOf( expired.getTurnsRemaining() )
} );
KoLmafiaASH.logScriptExecution( "Finished counter script: ", scriptFile.getName(), interpreter );
When a counter expires, that script is invoked via
boolean main( string name, int remaining );
In the context of my scripts, which only go places that take a single adventure at a time, remaining will always be 0, and the semirare (whatever) will occur on the very next adventure.
VMF contains a function:
void main()
This is the method which is invoked if you simply execute the script. I wonder if I could overload it and have
boolean main( string name, int remaining )
and simply set VMF as its own counterScript while it is executing, and thereby having access to all its own internal state? Intriguing!