Skip to main content
pokeemerald’s script engine drives all in-game events — NPC dialogue, item pickups, flag checks, and more. Scripts are written in GBA scripting assembly and executed by the interpreter in src/script.c and src/scrcmd.c.

Script files

Scripts in data/event_scripts.s use pokeemerald’s custom preproc macro format. poryscript is recommended for writing new scripts — it compiles a higher-level language to the binary script format and has a VS Code extension.

Script command table

data/script_cmd_table.inc assigns each opcode a constant name and a C handler. For example:
The full table is in data/script_cmd_table.inc. Handler implementations live in src/scrcmd.c.

Specials table

data/specials.inc defines gSpecials, the table of C functions that scripts can invoke via the special command. Each entry is assigned an index automatically using def_special. A selection of real entries:
Call a special by name from a script:

Basic script syntax

Scripts are label-terminated lists of commands in ARM assembly syntax:
Always pair lock with release and end every script path. Forgetting release will freeze the player’s movement.

Common script commands

MSGBOX types

Map scripts

Map scripts run automatically at specific lifecycle points. Attach them in the map’s .inc file using:

Using poryscript

poryscript compiles a higher-level scripting language to the binary format expected by pokeemerald. It removes boilerplate and makes branching logic readable.
1

Install poryscript

Download the latest release binary from the poryscript releases page and place it in your PATH, or in the repository root.
2

Write a .pory file

3

Compile to script binary

Then #include the output file from data/event_scripts.s.
4

Install the VS Code extension

Search for poryscript in the VS Code Extensions panel, or install karathan.poryscript directly. It provides syntax highlighting and snippets.