Scripts
A script is a small Lua program that reads what Prime Motion knows about the machine and the job, the loaded tool, the datum, the parts count, the controller's pins, and decides: CONTINUE, SKIP or ABORT. Scripts are written to guard a moment: refuse to start when the datum is in doubt, or warn when the feed override is off during a finishing pass.
Scripts live in the Macros tab beside G-code macros, with a Lua badge and a Test button.
The included samples
Eight samples show what a script can do. Each has a Test button, and none is attached to any moment by default.
| Sample | What it checks |
|---|---|
| Tool wear check | The loaded tool's measured length against an expected length, refusing when it has drifted past a limit |
| Dust boot home guard | A grblHAL input pin, so homing is refused while the dust boot is down |
| Refuse when the datum is doubted | The work coordinate system is known, its datum is not in doubt, and no G92 offset is in effect |
| Refuse when the tool is unmeasured | The loaded tool is known and has been measured |
| Refuse on a stale tool record | The tool record is current and was measured within a number of hours |
| Parts target alert | The parts count against a target, logging or refusing at the target |
| Warn on a feed override during a finishing pass | The feed override against a band around 100% |
| Read every fact (reference) | Logs every value a script can read, and decides nothing |
Testing a script
Tap Test on a script. The Test name drawer shows its Values (the parameters the script declares, with their defaults) and Test.
- Adjust the values if you want.
- Tap Test. The script runs once against the live machine's facts. Nothing is sent to the controller.
- Read the Verdict — CONTINUE, SKIP or ABORT — its explanation, and the Log the script wrote.

Testing is the way to see what a script would decide right now, before relying on it.
Importing your own
Scripts and G-code macros are imported from one folder on the tablet: Android/data/com.primemotion/files/macros. Copy .lua, .nc, .gcode or .tap files there with the Files app or a computer.
- In Macros, tap Import. The Import a macro drawer lists the files in the folder.
- Re-scan reads the folder again if you have just copied a file.
- Each file shows its name, whether it is LUA or GCODE, and any problem that stops it being imported, such as a line the reader rejected.
- Tap Import beside a file. It joins the list under the category its header names, or Custom.

A file already imported says so, and Re-import adds a second copy; it does not update the first. Delete the old copy if you meant to replace it.
Write pm.lua writes a description of everything a script can read and call into the same folder, for your editor to use while you write.
Changing a script
A script's ⋮ → Edit lets you change its name, category and description. Its code shows under Script (read-only — edit it where you wrote it), with the parameters and needs its header declares, and cannot be typed into. To change the code, edit the file, copy it into the folder again, Re-import it and delete the old copy.