Workers
trigscript/workers puts new workers to work. A worker rallied to a mineral field
normally walks to it and stands there; with this module it starts mining as soon as it
comes out.
import { autoMining } from "trigscript/workers";
autoMining(); // at the top of the script: on for the whole game
For every human player, a newly trained SCV or Probe, or a Drone hatched from a Larva, looks at the rally point of the building that made it:
- On a mineral field, it mines that field.
- On a finished Refinery, Extractor or Assimilator of its own player, it gathers gas from it.
- Anywhere else (the ground, a bare geyser, a gas building still being built, another player's gas building, a field mined out), it walks to the rally point as it always has.
It acts once, as the worker comes out, so an order the player gives afterwards stands. Computer players' workers and units made by Create Unit are left alone. A field or a gas building that is already busy is the game's to sort out, as it is when the player right-clicks it.
Where the call goes. autoMining() makes a program, so the call goes at the top of a
script, outside program(). Inside program() or a listener it is an error at the call.
Once is enough: a second call, in the same file or another, adds nothing.
The order it gives is u.gather(target), which a program of your own can give too (What
a unit can be told). gather itself does
not look at whose gas building it is or whether it is finished; autoMining() checks both
before it gives the order.
| Name | What it does |
|---|---|
autoMining() |
Turn auto-mining on for the whole game. At the top of a script only. |