Atrinik Client 4.0
Since a program can't possibly have every single feature users want, scripting is used, which provides additional features.
The script is a program which is external to the client. It can be written in a wide range of languages, including C, Java, Perl, Python, Bash, PHP, anything you can think about. How can this be possible? Let's take a look at what happens when you type "echo hello world" on a shell prompt. Sure it writes on your terminal "hello world". And if you are in a graphical shell prompt? It appears in the graphical console! Some process changed your request of writing to screen to a complex process of getting system's font and rendering the line in the specified window at the specified position. All this is because when you ask to "write hello world to screen" you really ask to "write hello world to the standard output device". This standard output device is called stdout. There is also the stdin, which most of the time is your keyboard and stderr, the standard error device being most of the time the same as stdout.
Now what Atrinik client uses is exactly the same trick as the graphical console. When the client runs a script, it changes the script's stdin and replaces the keyboard input with it's own orders (using a pipe). And it changes the stdout so instead of writing to screen, the script sends data to the client (using another pipe). And this is how any language can be used. Because every language can write to the screen and read from the keyboard!
Consider the following example:
The above example would, when compiled and executed by the client, use the /say command to output the message "Hello World." to everyone in hearing range.
Another example is this:
The above example would make your character go south, west, north and east, repeating the process 4 times.
The stdout has something called a buffer. When you write to output device, it's not immediately sent to it. For performance reasons, successive prints to stdout are grouped. Most of the time, \n is enough to force sending of data, but we ensure all the data is sent to client by flushing the stdout (force empty buffer). In the future, when you think client didn't get a command but the script did send it, ensure you flushed stdout.
This section documents all the possible commands a script can use to make the client do something.
When something happens, events can be triggered. For example, when server sends stats update, the stats event is triggered. This can be useful for scripts watching food and eat something when it reaches critical point, or if hp goes way too down and there is grace to be spared cast a healing spell or find a potion of healing in inventory and apply it.