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.
- Mathtrigscript/math is for things that move: a value that follows another, a glide from one place to another that slows at the end, the distance and the angle between two points.
- Randomtrigscript/random is chance in the words a map maker uses: one time in four, a number from 1 to 3, one of a list.
- Timerstrigscript/timers is time without a loop of your own: something every ten seconds, once in three, a cooldown, a round's clock.
- SignalsA Signal is an event of your own.
- UItrigscript/ui builds a player's text area out of pieces: a panel with a title, a meter, a menu chosen with the keyboard, a dialog typed out a character at a time.
- Cutscenestrigscript/cutscene acts out a scene: the camera looks, pans, follows a unit and shakes, units walk to their marks, and a portrait speaks a line.
- Fogtrigscript/fog draws pictures in the fog of war.
- Screentrigscript/screen is a grid of pixels shown on the map as units, so the minimap shows the picture: a game of Snake or Tetris played on the minimap, a score in big digits.
- Musictrigscript/music plays music written as patterns: a note's name per step, held with -, rests with ..
- Libraries from other pluginsA plugin can provide a library of its own: TrigScript modules a script imports by the library's name, as it imports the standard library by trigscript/….