scmJS docs

TrigScript library

The modules that come with TrigScript: maths, chance, timers, signals, menus and dialogs, cutscenes, the fog as a picture, pixel screens and music, with an example of each.

TrigScript comes with nine modules written for programs: motion and maths, chance, timers, events of your own, menus and dialogs in the text area, cutscenes, pictures drawn in the fog of war, pixel screens on the minimap, and music. A script imports what it needs:

import { chance, range } from "trigscript/random";
import { every, SECOND } from "trigscript/timers";

program(async () => {
  every(10 * SECOND, (n) => createUnit(P8, units.ZergZergling, range(n, n + 3), locations.Spawn));
  while (true) {
    if (keyPressed(P1, "Space") && chance(25)) print("A lucky shot.");
    await nextFrame();
  }
});

Each module is TrigScript, written the way your own files are, and only the modules a script imports go into the map. In the editor, hovering a name shows its documentation. These pages show what each module is for, with an example to start from and a table of what it has. The language the examples are written in is the subject of the TrigScript language guide.

Module What it is for
trigscript/math Easing, distances, angles, and Vec, a point of two fixed numbers
trigscript/random chance, range, pick, weighted, shuffle, and a seeded Random
trigscript/timers every, after, Cooldown, Countdown, Stopwatch, and loops spread over frames
trigscript/signals Signal, an event of your own that several parts of a map listen to
trigscript/ui Meters, panels, menus and dialogs in a player's text area
trigscript/cutscene A camera that pans and follows, units that walk to a mark, lines spoken by a portrait
trigscript/fog The fog of war as a picture: discs, rectangles, pictures, columns, videos
trigscript/screen A grid of pixels shown on the map and the minimap as units
trigscript/music Instruments, patterns and songs, played note by note or mixed when the script is built

Other plugins can provide libraries of their own; see Libraries from other plugins.

Some modules need something from the map, and they say so on their pages. fog, screen and cutscene each take one of the map's first 63 locations that the map does not use. The reason each location was taken shows with the map's requirements. fog uses eleven flying hero unit types as its brushes, and screen needs players set up for its colours.

Every example on these pages compiles as it is written, against a map with the locations Beacon, Spawn and Base. A line that ends with a comment such as // 50 prints that when the example runs.