Okay, I have been giving this a lot of thought, and I am really going to try and give some relevant and useful examples here.
I can see a use for three distinct "user interaction" functions (I know Hola will hate me for even suggesting these, sorry... but I really am a fan of the tool, and I think these will truly enhance it's capabilities). I'll detail these now for complete clarity on my intentions:
Function | Displays a modal dialog box with definable prompt text and... | Usage |
Input | an input box (returns the input to a variable) | input("prompt text",variable) |
Confirm | yes/no buttons (returns boolean true/false) | confirm("prompt text",variable) |
Select | a drop-down selector (returns value set in comma delimited list) | select("prompt text","choices,comma,delimited",variable) |
So let's say you want to script out your entire day's worth of adventures in one script (ambitious, ain't it?!?), and you notice that today is a Moxie day, and you happen to have a moxie character. You'd want to maximize your adventuring to take advantage of that, right? Then you might want to do a little meatfarming, and maybe throw in a few turns ultra-rare hunting or other adventure waster.
Here I'm just going to make up some code... it's just off the cuff, and obviously not optimized, so don't laugh at my laughable coding skillz...
#EXAMPLE SCRIPT USING USEFUL USER INPUT
#start with breakfast, of course
cli_execute("breakfast");
#apply summoning gear for maximum MP
outfit("MaxMyst");
#get candyhearts (a wishful mod of my candyhearts script)
input("Enter Max MP cost for Candy Heart Summoning",sumMax
);
confirm("Use beanbag chair to recover MP?",allowBB
);
int candyCount
= 0;
if(have_skill($skill[Summon Candy Heart
])){
while(mp_cost($skill[Summon Candy Heart
]) <= sumMax
&& mp_cost($skill[Summon Candy Heart
]) < my_maxMP()){
#I'm just going to truncate the script here... no need get that verbose in this example
}
}
print("Summoned " + int_to_string(candyCount
) + " Candy Hearts total.");
#Now check to see if user wants to do statfarming today
confirm("Do you want to do any statfarming today?",statFarm
);
if(statFarm
){
select("Optimize Statfarming for which stat?",
"Muscle,Mysticality,Moxie",statSelect
);
#so here is where the script to statfarm would go, keying off of the statSelect variable
}
#get ready to meatfarm
outfit("meatfarming");
input("How many turns to meatfarm today?",meatAdv
);
int advCount
= 0;
while(advCount
<= meatAdv
){
#insert your meatfarming script here, it will iterate as long as the turn counter is less than or equal to the value you just specified above
advCount
= (advCount
+ 1);
}
#decision gate! what to do with the rest of the day?
select("You have " + my_adventures() + " remaining today. What would you like to do?",
"Ultra-Rare Farm,End Script,Exit KolMafia",whatDo
);
#switch/case statements would be useful here... does that exist in KoLMafia? Or more wishful thinking??
if(whatDo
= "Ultra-Rare Farm"){
input("How many turns to burn uselessly attempting to farm for ultra-rares?",urfBurn
);
#so here is where the completely useless ultra-rare farming script would go, only wasting the turns specified in urfBurn ;D
}
#I'm just guessing at how you would exit the script here
cli_execute("abort Script completed, thanks for playing! Returning to KoLMafia...");
#user chooses to exit this time
if(whatDo
= "Exit KolMafia"){
confirm("Are you sure you wish to logoff from KoL and exit KoLMafia?",confirmExit
);
if(confirmExit
){
outfit("pajamas");
cli_execute("exit");
}
}
#END EXAMPLE SCRIPT
So I hope that my efforts to give a well-thought out, viable script example were successful.
I really think that adding user input will expand the utility of KoLMafia quite a bit... and I can't see how you would do all of the interactions with a kludge or workaround here.
Granted, it's less automated than the usual script, but it does account for more real-world variables like remaining turns for the day, stat-days, etc. Plus, people can be fickle... some days I just want to burn 20 or 30 turns on the slim chance of finding that elusive Baio or IDMG... ;D