KoLmafia Guide: Running ASH Scripts
KoLmafia has the capability to execute scripts which can perform just about any KoL action. Mafia scripting uses an .ash extension and is simply a text file that contains a bunch of Mafia commands with some programming language constructs as needed. You can browse, download, and execute scripts that other people have written to help automate specific functions or expand Mafia capabilities.
This poses a bit of a security risk, obviously. Mafia is all open-source and examined by many people and is relatively trustworthy. Some random dude's script.... not so much. Feel free to skip this lesson if this makes you nervous. Note that scripts can be extremely helpful though, so it is worth learning about them.
In this lesson, we are going to find a simple script, download it, store it, then execute it.
- First, we need to find a script we want to execute. For this lesson, point your browser to the KoLmafia forum. This mafia forum has a compendium of various scripts that you can look through in the future. For now, in , scroll to the last entry and find the most updated Tattoo.ash attachment.
- Click and download the Tattoos.ash attachment. You might have to join the KoLmafia forum to do the download. It is not a bad idea to do so anyways, so go ahead and do it. Or you can cut&paste from the bottom of this page into a Tattoos.ash text file.
- Go find the downloaded Tattoos.ash on your computer.
- Open the script using Notepad or similar text browser. Take a look. This is just so you can see what a script looks like, and also for your own peace of mind.
- Do a Find, and look for "buy", "sell", "notify", and "send" text. This is a quick security check. Notify is a one-time mailing to the developer of a script which just lets them know you use their script. It makes the script writers happy, I guess. Send/csend can actually mail people Meat or Items so ensure that nothing funny is going on there. Buy/Sell deals with item manipulation. You want to make sure a script is not gonna go sell all your stuff or buy expensive things. Even the best intended script can bankrupt you.
- Move the Tattoos.ash script to where your KoL executable lives. Remember in our first lesson we put KoLmafia in a folder. Since then, Mafia created several sub-folders where it stores its settings and stuff. In particular, a sub-directory called 'Scripts' should be present. Move Tattoos.ash into the scripts subdirectory. (For users on non-Windows, refer to Mafia directories for OS-specific directory locations.)
- At the top, click Scripts and 'Refresh Menu'. Go to Scripts again and you will see 'Tattoo.ash' in the list. You could click it to execute. Do not do this right now though.
- Back in Mafia, click the Graphical CLI tab.
- At the very bottom of the screen there is a text entry field. Type Tattoos.ash and hit enter. (or Tattoos will suffice)
- The Tattoos.ash will then be executed. I am assuming that you finished the Artist quest as it is one of the first ones you received. If so, the script will equip any outfit that you don't have a trophy for already then visit the Tattoo Artist. If you have not done the artist quest this ascension, I have no idea what the script does.
In any case, you will see exactly what the script does since you are already in the CLI tab.
Anyways, this script is pretty cool. Normally it takes a good deal of work to determine when you have acquired a 'new' outfit that you have not received a tattoo for. Assuming you happen to know you have a new outfit, you now have to equip it, visit the Tattoo shop, then put your original equipment back on. This script does this all for you! It searches every single outfit you possess, sees if you have the tattoo and if not, it gets it for you. It also tells you which outfits you are lacking for unreceived tattoos. Pretty cool huh?
Bonus 1) Browse thebriefly. You can see that there are some pretty cool scripts available, such as ones that automate several annoying aspects of quests for you. You might note that some scripts have prerequisites. One script in particular, ZLib, was created solely as a programming library for other script-writers and is widely used.
Bonus 2) I just started doing the Slime Tube and it sure is a pain. I found a cool slime.ash program which would outfit you, fight the slime, then rinse off when the Covered In Slime effect would kill you. However, it would make me take up to 99% of my HPs in Slime, then waste tons of healing aids to get me back to max. I modified it to auto-rinse after taking 500 damage from a single Covered in Slime effect. This let me kill slime without needing any healing effects at all.
The point is that it is very do-able to download someone else's script then hack it to make it do what you want it to do... or to remove undesired behavior. (notifys, use of consumables, buying things from the mall, etc)
BOTTOM LINE: Learning how to safely execute other people's scripts can be extremely helpful. Just about anything you want to do, someone else has wanted to do it also, and probably has a script for it.
Continue to Lesson 14: Useful Commands