scmJS docs

Reading the game

Every quantity a condition compares is also a value. Leave the comparison and the amount out of the call, and it is a read, a number like any other:

program(() => {
  let price = 50;
  // a condition, as ever:
  if (deaths(P1, units.TerranMarine, ">=", 10)) print("ten lost");
  let lost = deaths(P1, units.TerranMarine);             // a read
  if (minerals(CurrentPlayer) > price * 2) price += lost; // compared with a variable
  setResources(P2, "set", minerals(P1) / 2, "ore");      // as an action's amount
  let here = bring(P2, units.ZergZergling, locations.Pen);
  print(`${here} in the pen`);
});

That works for deaths, kill, bring, command, accumulate, score, opponents, countdownTimer and elapsedTime. The common ones have plainer names: minerals(p), gas(p), resources(p, "oreAndGas"), countUnits(p, unit, location?), kills(p, unit), countdown() and elapsed().

About the players: race(p) compared with races.Zerg, .Terran or .Protoss; slot(p) compared with slots.Human, .Computer, .Empty, .Rescuable or .Neutral; isHuman(p); hasLeft(p), for a player whose slot was taken and who is gone (a slot nobody took counts too, and a computer never leaves); and supply(p, "used" | "max" | "provided", race?), as the top bar shows it.