KoLmafia Guide: Logout script
We are putting a lot of stuff we learned together for this next one. It is a script you would run right before logging out for the day. It automatically does all the stuff that you probably want to do before logging out. We will learn a few new things here, but you know most of it already.
a) We've seen the buffBot and Wait code already. In this case, we want to have Ode to Booze readied BEFORE we drink our nightcap!
b) For a moxie player with Superhuman Cocktailcrafting, you can improve components. You always wanna use all 10 usages per day. Note the stills_available() function. I then buy some basic booze if needed, then use create() to make the appropriate upgrade to that booze. You can change this to whatever booze/fruit improvement you wish.
c) You can see my lame PvP script. A better alternative is probably to say, "IF i have any attacks remaining, Print a warning to the user and then Abort". I figure that if I am ready to log out, I don't want to mess with PvP.
d) So I actually cobbled enough meat (thanks to Crimbo) to buy a Libram! I want to be sure to use up any remaining mana to use the Libram...especially if I have forgotten to use it at all that day!
I use a new loop, the While loop. As long as my MP is enough to cast the Love Song, then I cast it.
Bonus) A smart thing to do here is to include usage of any 'per day' MP restores. I don't actually HAVE any at the moment, but Nunnery MP regen, VIP clan key, and whatever other stuff that hasn't been used up already could be used. You would do so by adding another while loop most likely that says, "While you still have a way to restore your mana for free, do so, then Do the Libram summon loop".
f) Note how you change outfits. This requires you to have previously saved a specific custom outfit called 'TimeGainer', by equipping items that give more PvP or Adventures per day. Changing outfits is super helpful and you can use this command to great effect. Obviously, name it whatever you'd like.
g) Note my comment below the change outfits. You can simply 'maximize adv' to make Mafia auto-outfit with you to max out adventure gains. I'd save off a specific outfit instead though as I combine both PvP and adventures. But the Maximize call can be pretty handy... lets say you are making a Hobopolis script. Being able to Maximize a particular resistance can be really handy.
h) At the very end, I overdrink my nightcap cocktail. I ASSUME I am at right under maximum drunkenness. Therefore I don't do any checks. Also note that a DRINK command probably won't work. Mafia will prevent you from overdrinking unless you specifically override that preference with the Overdrink command. Note that I overdrink at the END of the script, since you are basically done once you are drunk.
i) You can always add whatever else you want for a logout script like this. Make reminders to use up your 1/day stuff, and abort the script if you have not. Maybe you want to summon a demon every day and either want to do it automatically or warn you if you have not done so. KoLmafia breakfast can handle most of this stuff for you though.
j) Finally, if you wanted you could go back to the Breakfast tab and include this as your new 'logout script'. When you log out of KoLmafia, it will first run this script before quitting. I prefer to run it manually, but you can certainly automate it if desired. (see our Breakfast Lesson above for details)