Scripting
Real Go, in a sandbox
A map's rules are a standard Go program. The editor compiles it with the ordinary Go toolchain to WebAssembly (GOOS=wasip1). The engine runs it in wasmtime, a WebAssembly runtime, inside the simulation. A script gets a fixed amount of computing per call and a memory cap. There is no custom language and no dialect.
| W4 | Warcraft III | |
|---|---|---|
| Language | Go | JASS, with GUI triggers that generate it. Lua in newer versions |
| Editor | Your own: Zed, VS Code, Neovim, GoLand | The World Editor's built-in text box |
| Completion and errors | gopls, the standard Go language server | Limited |
| Libraries | The Go standard library | The game's native functions |
| Types | Static, checked when you build | Dynamic or loosely typed |
| Tests | go test on pure logic |
None |
| Version control | Plain text files in a folder | Inside a binary map archive |
We picked Go because it is small, compiles fast, reads easily and has good tools. A script from a map you downloaded cannot read your disk or reach the network.
Deterministic
A script runs inside the simulation at fixed steps and sees the game's time and the game's state. If it sticks to the API, the same inputs give the same game on every computer, which is what lockstep multiplayer needs. The sandbox closes the disk and the network, and limits compute and memory. It also takes the machine out of the picture: the clock a script sees is game time, and anything it asks the system for, like random numbers, comes from the game's seed, which every player and every replay shares. game.Random is the plain way to roll a number. The rules in Multiplayer rules cover the rest.
An API generated from the code
The Scripting API reference is generated from the doc comments of the Go SDK that ships with the editor. The SDK is written once per computer into your data folder and every map points at it. Maps stay small, and a map is built against the API of the editor that built it.
What is next
Hot reload of a script into a running game, sound and camera from scripts, more events (orders, damage, regions) and a richer interface API. A GUI trigger builder is a later, optional layer on top of Go. See What is next.