Posted by Kyle Hankinson June 16th, 2026
The Scripts section is where you keep reusable JavaScript. Instead of copying the same code into every trigger and alias, you write a function once in a script and pull it in wherever you need it.
Every trigger and alias runs in its own JavaScript context, so the functions you define in a script are not available everywhere automatically. You make them available by including the script.
The include function loads another script by name and makes everything it defines available to the current trigger, alias, or script. scriptName is the title of the script as it appears in the Scripts list, and is not case sensitive.
require is identical to include. Use whichever reads better to you.
A script is only ever included once per run, so it is safe to include the same script from several places, and scripts may include other scripts.
Create a script named Combat with a couple of helpers:
// Script: Combat
function herb(name) {
command('get ' + name + ' from pack');
command('eat ' + name);
}
function quaff(potion) {
command('quaff ' + potion);
}
To use it from a trigger, include the script at the top of the action, then call the function. (Capture groups from the trigger's pattern are available via textOf(1), textOf(2), and so on. See the Regular expression tips post.)
// Trigger action. Pattern: ^You feel hungry
include('Combat');
herb('bloodroot');
An alias works exactly the same way. Here the first capture group of the alias pattern is passed straight through:
// Alias action. Pattern: ^h (\w+)
include('Combat');
herb(textOf(1));
Because the include runs first, herb is ready to call on the lines that follow.
When you change a script, reload so your triggers and aliases pick up the new code:
Reloads every trigger, alias, and script from disk and reports how many of each were loaded.
Combat script and a Travel script) and include only what each trigger needs.# commands.