StDoodle
Minion
(NB: I felt like telling a story. Please keep this in mind. Also, I greatly appreciate every bit of work that has gone into KoLmafia; please don't take any of this as whining or bitching. Just lousy storytelling.
)
Once upon a time, shortly after combat macros were introduced into KoL, jasonharper did some very snazzy implementation of their use by KoLmafia. We rejoiced at the savings in real-life time & server hits, but it didn't take long for us to ask "so when can we call or generate a macro from a consult script?" We were told that for various reasons, this wouldn't be a simple task, so it would have to go on the back burner. Alas, both jasonharper & Veracity have found their KoL(mafia) time at a greater premium than before, and so-called "employScripts" have been indefinitely shelved.
But fear not! For I have dragged from the darkness a suitable method of "faking" such an employ script.
The basic concept is fairly simple; in a consult script, you have access to basically all of the same functions as you normally would in an ash script. In fact, it isn't at all unheard of to use visit_url() to scrape page text before figuring out what your next action should be. So why not make use of CDM's "secret" ability for scripters to include a macro in their URL?
Basically, you want to use:
where macro() is a function that builds your macro & returns it as a string. It's actually simpler than one might think; KoLmafia automatically does the necessary URL encoding needed, so one doesn't even need to replace spaces with "+" or any of that junk. Just type your macro with a semicolon between what would normally be the different lines in your macro (remembering of course that predicate lines need to be kept together), and voila! it works.
Ok, perhaps it isn't THAT easy. The ability to use "&&" and "||" in your macro is quite useful. However, I couldn't for the life of me figure out what format the ampersand needed to be in inside of the script such that it would make it to KoL as "&&". In a fit of despair & frustration, I tried something that I THOUGHT was completely wacky; "ANDAND" as plain text. Low and behold, it worked! I suspect "OROR" would work as well, though I have yet to test it.
One more little caveat to keep in mind; KoLmafia's CCS doesn't exactly play nicely with a consult script that generates a macro and uses visit_url() to run it. If you want, for example, to run your consult script, come back to your CCS, perhaps do other actions, etc., you'll find that this won't work; KoLmafia is pretty much "lost" once you've done a macro from inside an ash script. To deal with this, it's best to handle the entire combat from within the single consult.
It IS possible to run several macros; I've tested a consult script that generates one macro, submits it, then generates another macro and submits it as well, and it worked perfectly. Just realize that if, for any reason, combat has not finished when your script ends, KoLmafia will almost certainly sit out the rest of your combat, waiting for manual input.
Ok, now that I have that out there, please let me know what I've missed, what else we need to keep in mind, etc. I'd love to get this information up on the wiki!
Happy scripting!
Edit: After additional testing, "OROR" does indeed work. Also, this is a KoL-itself thing; you can write your in-game macros with "ANDAND" and "OROR" and they'll work just fine.

Once upon a time, shortly after combat macros were introduced into KoL, jasonharper did some very snazzy implementation of their use by KoLmafia. We rejoiced at the savings in real-life time & server hits, but it didn't take long for us to ask "so when can we call or generate a macro from a consult script?" We were told that for various reasons, this wouldn't be a simple task, so it would have to go on the back burner. Alas, both jasonharper & Veracity have found their KoL(mafia) time at a greater premium than before, and so-called "employScripts" have been indefinitely shelved.
But fear not! For I have dragged from the darkness a suitable method of "faking" such an employ script.
The basic concept is fairly simple; in a consult script, you have access to basically all of the same functions as you normally would in an ash script. In fact, it isn't at all unheard of to use visit_url() to scrape page text before figuring out what your next action should be. So why not make use of CDM's "secret" ability for scripters to include a macro in their URL?
Basically, you want to use:
Code:
visit_url("fight.php?action=macro¯otext=" + macro())
Ok, perhaps it isn't THAT easy. The ability to use "&&" and "||" in your macro is quite useful. However, I couldn't for the life of me figure out what format the ampersand needed to be in inside of the script such that it would make it to KoL as "&&". In a fit of despair & frustration, I tried something that I THOUGHT was completely wacky; "ANDAND" as plain text. Low and behold, it worked! I suspect "OROR" would work as well, though I have yet to test it.
One more little caveat to keep in mind; KoLmafia's CCS doesn't exactly play nicely with a consult script that generates a macro and uses visit_url() to run it. If you want, for example, to run your consult script, come back to your CCS, perhaps do other actions, etc., you'll find that this won't work; KoLmafia is pretty much "lost" once you've done a macro from inside an ash script. To deal with this, it's best to handle the entire combat from within the single consult.
It IS possible to run several macros; I've tested a consult script that generates one macro, submits it, then generates another macro and submits it as well, and it worked perfectly. Just realize that if, for any reason, combat has not finished when your script ends, KoLmafia will almost certainly sit out the rest of your combat, waiting for manual input.
Ok, now that I have that out there, please let me know what I've missed, what else we need to keep in mind, etc. I'd love to get this information up on the wiki!
Happy scripting!
Edit: After additional testing, "OROR" does indeed work. Also, this is a KoL-itself thing; you can write your in-game macros with "ANDAND" and "OROR" and they'll work just fine.
Last edited: