Difference between revisions of "Miscellaneous ASH Features"

From Kolmafia
Jump to navigation Jump to search
imported>Zarqon
(Fleshed out some of the script hooks, with usage information.)
imported>StDoodle
Line 23: Line 23:
  
 
* Between Battle (betweenBattleScript)<br />
 
* Between Battle (betweenBattleScript)<br />
:Executed whenever mafia is about to enter a combat (before every adventure if auto-adventuring, or before using a combat item (such as black pudding).  Does not require any special main() declaration.  (Example: Zarqon's [[http://kolmafia.us/showthread.php?t=1240 Best Between Battle]])
+
:Executed whenever mafia is about to enter a combat (before every adventure if auto-adventuring, or before using a combat item (such as black pudding).  Does not require any special main() declaration.  (Example: Zarqon's [http://kolmafia.us/showthread.php?t=1240 Best Between Battle])
 
* Buy (buyScript)<br />
 
* Buy (buyScript)<br />
 
:Executed when / how?
 
:Executed when / how?

Revision as of 06:44, 19 April 2010

Special Syntax Functions

notify

Used to send a simple kmail to the script's author, letting them know you use their script.

import

Used to load an external script into your current one.

Comments

Adding Comments to your code can make it much easier to maintain, and helps other users understand what's going on.

Errors

For help when things go wrong, please see the page on ASH Errors.

Additional Script Uses

In addition to regular scripts, relay override scripts, and consult scripts, mafia has a few other hooks for adding event-driven scripts. These situations are listed below, along with the preference that you can set a script name to (in parentheses).

  • Between Battle (betweenBattleScript)
Executed whenever mafia is about to enter a combat (before every adventure if auto-adventuring, or before using a combat item (such as black pudding). Does not require any special main() declaration. (Example: Zarqon's Best Between Battle)
  • Buy (buyScript)
Executed when / how?
  • Chatbot (chatbotScript)
This works how?
  • Counters (counterScript)
Will execute whenever a counter is about to expire. Requires a special main declaration: boolean main(string name, int remain). These values will be supplied by mafia when the script is automatically called, and the return value will determine whether mafia continues operation (true) or aborts (false). Name will be the name of the counter that is about to expire, and remain is the number of turns remaining before the counter expires. Remain will usually be 0, but may be higher if you are about to multi-create items, adventure underwater, or take a vacation. (Example: Bale's [CounterChecker].)
  • Login (loginScript)
This script is immediately executed once your character is logged in. Requires no special main() declaration.
  • Logout (logoutScript)
Same as the loginScript, but runs on logout. Note that an abort() in the script won't stop a logout unless the logout was called in (specific ways, please list).
  • Planting (plantingScript)
Halp!
  • Post-Ascension (postAscensionScript)
Executed at once when your character starts a new ascension.
  • Pre-Ascension (preAscensionScript)
Executed right before entering Valhalla.
  • Recovery (recoveryScript)
Executed whenever mafia would recover your HP / MP. Requires a special main() declaration: boolean main(string type, int amount). These values will be supplied when mafia automatically calls the script, and the return value will determine whether to continue operation (true) or abort (false). Type will be either "HP" or "MP" and amount will be the desired amount of restoration needed. (0 for amount has special meaning? Does this effect the whole negative status effects handling?) (Example: Bale's [Universal Recovery])

A little CLI help

Two CLI commands are of great use to ASH scripters:

  • ashref allows one to get a list of ASH functions
  • ash or ashq allows one to run ASH directly on the CLI.

Attention KoLmafia Experts!

We need your help; some details of this function's operation are unknown or unclear.

The following specific question has been raised:

  • Where are all the other places a script can be used? Help plox.