WARNING! Never load or install scripts that you do not trust completely. You should preferably never install anything that you have not created yourself. Malicious scripts written by bad people may act as viruses, trojans or spyware. Malicious scripts may cause damage to your computer, your economy or your health! USE IT AT YOUR OWN RISK! Also make sure you read the EULA once again before you start delving into the wonderful world of scripting.

Scripts

The scripting system of BatClient is based upon BeanShell scripting. Fore more information about BeanShell visit http://www.beanshell.org. Scripts allow you to write small programs for particular events in the game. It is possible to call scripts from triggers and macros to perform whatever you write them to do. It is also possible to write scripts that are called when the client is started. You could for example write a particular script to generate a set of triggers or macros and distribute it as an add-on. Scripts are put into the user.dir/batclient/script folder and they are autoloaded when the client starts up or when you use the /scriptreload feature.

A script is basically a text file that include BeanShell/Java code. You can read more about the particular syntax of the beanshell scripts at the beanshell website. It supports both loosly written script code and full blown java code. You can write your scripts by using your favorite text editor and placing the files into the user.dir/batclient/scripts folder before you start the client or issue a /scriptreload command. You can also use the internal script editor inside the client to write and manage your scripts. The /scriptreload command will first remove every trigger and macro which are loaded through scripts before reloading all new scripts.

The following commands can be used to manage your scripts:
/scriptlist
/scriptreload
/scriptbootup

The scripts are called from different places in the client and you can also call on a script manually from the commandline, triggers or macros. When a script is called manually the "run()" method inside the script will be evaluated as default. To call a script you use the $ character infront of the script name. You can also call a particular method inside the script by adding .methodname to the scriptname. For example: $myScript.myMethod

Every script must define the SCRIPT_NAME variable. It is what will identify the script inside the client. This variable must be set to a unique string. For example:
SCRIPT_NAME = "myUniqueScript";

It is possible to define the SCRIPT_ON variable if you wish to turn a script off temporarily. If the variable is not defined the script is default on. To turn a script off define the variable as: "SCRIPT_ON = false;"

Script variables

Before a method in the script is evaluated certain variables will be set automatically. Some variables are only available for certain methods (described below) and some variables are global and can be accessed inside any of the methods described below. Javadoc for the interface is available in the help menu.


Script methods

The following methods can be defined to perform different things inside the client. The run() method is the standard method that will be called if the script is executed manually. You can also define your own methods and call them yourself. These methods listed here are called by the actual client when different events occurs.