scmJS docs

TrigScript

Triggers written as TypeScript: the script window, tests, triggers made by code, programs that run in the game on StarCraft: Remastered, examples and the reference.

TrigScript is a way to write triggers as code. The code is TypeScript and it lives inside the map. It is a plugin, on from the start: Triggers ▸ TrigScript… opens it as soon as a map is open.

Two ideas carry it. The files are real TypeScript and they run when the script is applied: every trigger() call they make becomes one trigger of the map, so a helper that returns the ten triggers a shop needs, a loop over the players, a table of waves and the whole standard library are there to write triggers with. Those are ordinary triggers, the same kind the Trigger Editor shows, and a map made of them plays on any version of the game.

Code inside program(() => { … }) runs in the game instead: variables, arrays, texts, functions, classes, loops and sleep, so a lives counter or a wave timer is written as a loop rather than as a dozen triggers with hand-numbered death counts. Programs are built into the map by the eudplib plugin, another default, when the map is saved, and a map with a program in it needs StarCraft: Remastered. A script that only calls trigger() never involves any of that.

The TrigScript editor on a wave-defence script: the files on the left and the code checked as you type