cli_execute()

From KoLMafia
Jump to: navigation, search

Function Syntax

boolean cli_execute(string command )

  • command is a cli command or commands to execute

This function passes the parameter command on to KoLmafia's CLI, which will execute it as if it were typed in through the normal interface. This function will return true if the CLI command executed properly, and false if it was unable to do so (for example, trying to execute an adventuring command while drunk). Though it's considered a "best practice" to use built-in ASH functions when possible, there are some instances (such as "maximize") where no ASH function exists to handle what needs to be done, and this function allows access to such commands from within an ASH script.

Code Samples

A basic leveling mood setup using CLI Execute as ASH does not have anything similar.

//Mood Name
cli_execute("mood MoxieLeveling");
cli_execute("mood clear");
//Remove Poisons
cli_execute("trigger gain_effect, somewhat poisoned, uneffect Somewhat Poisoned");
cli_execute("trigger gain_effect, Hardly Poisoned at All, uneffect Hardly Poisoned at All");
cli_execute("trigger gain_effect, A Little Bit Poisoned, uneffect A Little Bit Poisoned");
cli_execute("trigger gain_effect, Really Quite Poisoned, uneffect Really Quite Poisoned");
cli_execute("trigger gain_effect, Majorly Poisoned, uneffect Majorly Poisoned");
cli_execute("trigger gain_effect, Toad In The Hole, uneffect Toad In The Hole");
cli_execute("trigger gain_effect, just the best anapests, uneffect just the best anapests");
//Store Buffs
if (my_meat() >= 500)
   cli_execute("trigger lose_effect, Butt-Rock Hair, use 10 hair spray");
//Smiles
if (have_skill($skill[Knowing Smile]) && my_maxmp() >= 20) 
   cli_execute("trigger lose_effect, Knowing Smile, cast 1 Knowing Smile");
else if (have_skill($skill[disco smirk]) && my_maxmp() >= 20)
   cli_execute("trigger lose_effect, Disco Smirk, cast 1 Disco Smirk");
//DB Skills
if (have_skill($skill[Disco Aerobics]))
   cli_execute("trigger lose_effect, Disco State of Mind, cast 5 Disco Aerobics");
//At Skills
if (have_skill($skill[Moxie of the Mariachi]))
   cli_execute("trigger lose_effect, Mariachi Mood, cast 5 Moxie of the Mariachi");
//Songs   
if (have_skill($skill[The Moxious Madrigal]) && my_maxmp() >= 2)
   cli_execute("trigger lose_effect, The Moxious Madrigal, cast 1 The Moxious Madrigal");
//Execute the mood
cli_execute("mood execute");
Cli_execute is used most commonly for functions that do not have an ASH equivalent. More CLI commands can be found here or typing "help" into the CLI window.


This example maximizes your meat drop percentage and spends all of your adventures in the Castle

cli_execute("maximize meat, switch hobo monkey, -switch leprechaun");
adventure( my_adventures(), $location[Giant's Castle] );

CLI Equivalent

The function cli_execute() equivalents you!