Skip to content

Scripting Overview

github-actions[bot] edited this page Nov 3, 2026 · 5 revisions

Scripting Overview

SimpleAE: Scripting is an optional addon, shipped as a separate jar built from the same repository. It requires SimpleAE: ByteStorage.

  • Not installed → the Logic Bus and Logic Terminal do not exist in the game at all.
  • Installed → two new blocks, a creative tab, a server config, and new chapters in the Guide Book.

The addon bundles Rhino (a JavaScript engine for Java). Rhino is only inside the addon jar; the core mod never contains it.

Blocks

Block Role
Logic Bus Runs one JavaScript script. Sees its six neighbouring inventories and the network.
Logic Terminal Opens the script editor for every Logic Bus connected to the same network.

Both are normal network nodes: they must connect to an online controller (touching or via cables).

Workflow

  1. Place the Logic Terminal and one or more Logic Buses on the network.
  2. Put each Bus next to the inventory (chest, furnace, machine) it should control.
  3. Right-click the Terminal. Pick a Bus from the list on the left.
  4. Write the script in the editor, then press Save.
  5. Press Run. The status line and the log below the editor show what happens.

Buttons:

Button Action
Save Stores the script on the bus. Saving stops the bus, press Run to start it.
Run / Stop Starts or stops the script.
Reload Discards edits and reloads the script stored on the bus.
− / + Changes the run interval by 10 ticks.

The terminal must be within ~12 blocks of the player for actions to be accepted. If opsOnly is on and you aren't allowed, the terminal is read-only.

Execution model

// 1. The top level runs ONCE when the bus starts (compile + init).
var chest = side("up");
var counter = 0;

// 2. tick() runs every <interval> ticks.
function tick() {
  counter++;
}
  • A script must define function tick(), otherwise the bus reports an error.
  • Global variables persist between runs, but are reset when the script is saved, the world reloads, or the bus is restarted (the top level runs again).
  • The default interval is 20 ticks (1 s). The server enforces a minimum (default 10 ticks); max 1,200.
  • A bus runs only while it is enabled, its network is online, and scripting is enabled in the config.
  • Any error, or exceeding a limit, stops the bus, sets the status to ERROR: <reason> and writes it to the log.

Status values

Status Meaning
(empty) Never started
saved Script saved, bus stopped
running Active
stopped Stopped by the player
ERROR: … Stopped by an error (syntax error, runtime error, limit exceeded) with line number where available

Persistence

Script text, enabled flag and interval are stored in the block entity's NBT. Script variables and the log are not persisted. After a world restart an enabled bus recompiles and continues.

Clone this wiki locally