Run choice
Function Syntax
buffer run_choice(int choice )
- choice is the number of the choice option you wish to take. Use "-1" to automate the rest of the choice using existing choice adventure settings.
Proceeds to run a choice using your current KoLmafia settings. This function returns the HTML from the choice page (not just what is displayed, but all markup). Most commonly used to finish up choices started via visit_url().
Another handy use for this function is to finish up choices that were started in the relay browser, or were interrupted (i.e. mafia aborted for you to manually make a choice selection). Typing "ashq run_choice(choice)" into the CLI will finish up the choice for you using your selected choice. Note that "ashq" is necessary rather than "ash" to avoid spewing the entire choice results page into the CLI.
Code Sample
This is a personalized version of adv1() that is capable of returning information about which adventure is encountered so that you can look for a specific choice adventure. If a combat is encountered instead of a choice adventure, run_combat() is used.
int run_adv(location place) {
string page_text = to_url(place).visit_url();
string choiceAdventure = "-1";
matcher m_choice = create_matcher("whichchoice value=(\\d+)", page_text);
while(page_text.contains_text("choice.php")) {
m_choice.reset(page_text);
m_choice.find();
choiceAdventure = m_choice.group(1);
string choice_num = get_property("choiceAdventure"+ choiceAdventure);
if(choice_num == "0") abort("Manual Control for "+ choiceAdventure);
if(choice_num == "") abort("Unsupported Choice Adventure!");
page_text = run_choice(choice_num);
}
if(page_text.contains_text("Combat"))
run_combat();
return choiceAdventure.to_int();
}