Difference between revisions of "Cli execute"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
imported>Slyz
(add code sample)
Line 17: Line 17:
  
 
function_description=This function passes the parameter {{pspan|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.|
 
function_description=This function passes the parameter {{pspan|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.|
 +
 +
code1={{CodeSample|
 +
title=Code Sample|
 +
description=This example maximizes your meat drop percentage and spends all of your adventures in the Castle|
 +
code=
 +
<syntaxhighlight>
 +
cli_execute("maximize meat, switch hobomonkey, -switch leprechaun");
 +
adventure( my_adventures(), $location[Giant's Castle] );
 +
</syntaxhighlight>}}|
  
 
needscode=yes|
 
needscode=yes|

Revision as of 14:52, 31 March 2010

needs(code_samples);

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 Sample

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

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

CLI Equivalent

The function cli_execute() equivalents you!