scmJS docs

Quick start

This makes a map where Player 1 wins by walking a Marine onto a marked spot.

  1. Open a map, or make one with File ▸ New (Ctrl+N). In Scenario ▸ Player Settings, give Player 1 a fixed race such as Terran. A player left on User Selectable gets a melee base instead of the units you place; see Your first map.

  2. On the Units layer (U), pick Player 1 at the top of the palette and place a Terran Marine.

  3. On the Locations layer (L), drag a box a short walk away from the Marine. Double-click the box and name it Beacon.

  4. Open Triggers ▸ TrigScript…. Replace the contents of main.ts with:

    trigger(P1, [
      bring(P1, units.AnyUnit, locations.Beacon, ">=", 1),
    ], [
      displayText("You found the beacon."),
      victory(),
    ]);
    

    As you type locations., the editor offers the map's locations by name.

  5. Save the map (Ctrl+S). Saving applies the script: the trigger goes into the map's trigger list. The status bar at the bottom of the TrigScript window shows how many triggers the script made and where they start in the list, such as 1 trigger at #1.

  6. Press Play (F5) in the TrigScript window, or use Tools ▸ Test Map in the editor. The first time, Test Map needs to know where the game is; see Test Map. In the game, open Single Player ▸ Custom Game, pick the map from the scmJS folder, and choose Use Map Settings as the game type. Walk the Marine to the beacon.

To see what the script made, open the Trigger Editor (Ctrl+T). The trigger is there with a script badge. From here, Writing triggers explains the parts of a trigger, and Examples of triggers has complete scripts to start from.