Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/CryZe/asr-assemblyscript/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you through creating a brand-new auto splitter project from scratch using asr-assemblyscript. By the end you will have a fully compiled .wasm file that attaches to a game process and controls LiveSplit One’s timer automatically. All you need is Node.js (v16 or later) installed on your machine — the AssemblyScript compiler and the library itself are installed locally through npm.
1

Create the project folder

Create a directory for your auto splitter and navigate into it, then initialize a new npm project. Running npm init will prompt you for basic metadata; you can press Enter to accept the defaults for every field.
mkdir my-auto-splitter
cd my-auto-splitter
npm init
2

Install AssemblyScript and asr-assemblyscript

Install the AssemblyScript compiler as a dev dependency, then add asr-assemblyscript itself. Because asr-assemblyscript is distributed directly from GitHub rather than the npm registry, the second command uses the full repository URL.
npm install --save-dev assemblyscript
npm i --save https://github.com/CryZe/asr-assemblyscript
After this step your node_modules folder will contain both the assemblyscript compiler toolchain and the asr-assemblyscript library source files.
3

Initialize the AssemblyScript project

Use the AssemblyScript scaffolding tool (asinit) to generate the standard project layout. This creates the assembly/ source directory, a starter assembly/index.ts entry point, an asconfig.json compiler configuration file, and updates package.json with build scripts.
npx asinit .
4

Update the build scripts in package.json

The scaffolded build scripts do not yet reference asr-assemblyscript’s custom abort implementation, which the AssemblyScript runtime requires. Open package.json and replace the two asbuild script lines with the versions below so the compiler picks up the correct abort handler via the --use flag.
"asbuild:debug": "asc assembly/index.ts --target debug --use abort=~lib/asr-assemblyscript/runtime/abort",
"asbuild:release": "asc assembly/index.ts --target release --use abort=~lib/asr-assemblyscript/runtime/abort",
Your scripts section should look similar to this after the edit:
"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
  "asbuild:debug": "asc assembly/index.ts --target debug --use abort=~lib/asr-assemblyscript/runtime/abort",
  "asbuild:release": "asc assembly/index.ts --target release --use abort=~lib/asr-assemblyscript/runtime/abort"
},
The --use abort=~lib/asr-assemblyscript/runtime/abort flag tells the AssemblyScript compiler to substitute asr-assemblyscript’s abort function in place of the default one. Without it, unhandled errors inside the module will not be handled gracefully inside the sandboxed runtime.
5

Write your auto splitter and compile

Open assembly/index.ts and replace its contents with the example below. This minimal auto splitter imports the runtime side-effects module (which registers the custom abort handler), imports the timer and process modules, then exports the update() function that the runtime calls on every tick.
import "asr-assemblyscript/runtime";
import * as Timer from "asr-assemblyscript/timer";
import * as Process from "asr-assemblyscript/process";

// Store the process ID between ticks. 0 means not yet attached.
let processId: u64 = 0;

export function update(): void {
  // If we are not attached, try to attach to the game process.
  if (processId === 0) {
    processId = Process.attach("MyGame.exe");
    return;
  }

  // If the process has closed, detach and reset our stored ID.
  if (!Process.isOpen(processId)) {
    Process.detach(processId);
    processId = 0;
    return;
  }

  // We are attached and the process is open — start the timer.
  Timer.start();
}
Once your code is ready, compile it into a release WebAssembly binary:
npm run asbuild:release
The compiler will emit your finished auto splitter to:
build/release.wasm
To load your auto splitter in LiveSplit One, open Layout Settings, add an Auto Splitting Runtime component, and point it at your build/release.wasm file. LiveSplit One will begin calling update() automatically once the layout is active.

Next steps

You now have a working auto splitter skeleton. From here you can expand the update() function to read specific memory addresses using Process.read() or the typed watcher classes, fire Timer.split() when a level changes, call Timer.reset() on a new-game flag, or expose toggle options to runners with UserSettings.addBool(). Check out the guides below to go deeper.

Auto Splitter Lifecycle

Learn exactly when and how the runtime calls your update() function and how to manage process state across ticks.

Reading Memory

Use Process.read(), module addresses, and the watcher helper classes to track game values.

Build docs developers (and LLMs) love