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().
- A read means what its condition means: a force's minerals are the force's total, and
units.Mencounts what Bring counts. - A read is taken when its line runs.
let ore = minerals(P1)keeps the number, andminerals(P1)written twice reads twice. - What to read (the player, the unit, the location) is fixed when the script is applied.
countdown()andelapsed()count the game's own seconds, sixteen frames each, so at Fastest they run about one and a half times as fast assleep(seconds()): after fourteen seconds of sleeping,elapsed()reads 21.
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.