PRIME MOTION— Help
Search

Tools, Macros, Wizards & History › Scripts

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.

SampleWhat it checks
Tool wear checkThe loaded tool's measured length against an expected length, refusing when it has drifted past a limit
Dust boot home guardA grblHAL input pin, so homing is refused while the dust boot is down
Refuse when the datum is doubtedThe work coordinate system is known, its datum is not in doubt, and no G92 offset is in effect
Refuse when the tool is unmeasuredThe loaded tool is known and has been measured
Refuse on a stale tool recordThe tool record is current and was measured within a number of hours
Parts target alertThe parts count against a target, logging or refusing at the target
Warn on a feed override during a finishing passThe 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.

  1. Adjust the values if you want.
  2. Tap Test. The script runs once against the live machine's facts. Nothing is sent to the controller.
  3. Read the Verdict — CONTINUE, SKIP or ABORT — its explanation, and the Log the script wrote.
Testing the Refuse when the datum is doubted sample: the verdict, its explanation and the log
Testing the Refuse when the datum is doubted sample: the verdict, its explanation and the log

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.

  1. In Macros, tap Import. The Import a macro drawer lists the files in the folder.
  2. Re-scan reads the folder again if you have just copied a file.
  3. 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.
  4. Tap Import beside a file. It joins the list under the category its header names, or Custom.
Import a macro over the Macros list: the folder, Re-scan, Write pm.lua, and an already imported script with Re-import available
Import a macro over the Macros list: the folder, Re-scan, Write pm.lua, and an already imported script with Re-import available

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.

Still stuck? Contact support or email support@primemotioncnc.com.