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.

- Opening the scriptTriggers ▸ TrigScript… opens the map's script in a window laid out the way VS Code is, with the same keys.
- TestsA script can test itself.
- Beside the mapThe editor opens two ways.
- Writing triggersA trigger is one call:
- ProgramsEverything inside program(() => { … }) runs in the game:
- TrigScript beside TypeScriptOutside program() there is nothing to compare: the script is TypeScript, checked by the TypeScript compiler and run when it is applied, with the whole language and its standard library.
- ExamplesEach of these is a complete main.ts.
- ReferenceThe trigger form and its options: