Lua Triggers

Lua triggers run your own Lua script automatically when a controller event happens, such as power-on, homing, a tool change or an action button press. Use them to automate tasks, add safety checks or log events without changing the firmware.

Applies to
MASSO G3 and G3 Touch, Professional, v5.13+
Screen
F1-Setup › Custom Scripts (Lua)
API version
1.0.0
INFORMATION
Custom scripts need the Professional software level. Upgrade to Professional or see how to upgrade.

How triggers work

Each trigger is a fixed controller event. You attach a Lua script to it, and when the event happens the controller runs that script straight away. Most triggers don't return a value. Some, such as Before Tool Change, can return a control signal (continue, skip or abort) to change what the controller does next.

Triggers are grouped by category:

CategoryCovers
SystemPower-up and background events
HomingBefore, after and on error
I/O & SafetyE-Stop and door sensor
ProcessTool change
InterfaceAction buttons 1–16
JobEnd of job
INFORMATION
The Custom Scripts window lists some categories that are not active yet, such as M-Codes, Spindle and Auto Tool Zero Probe. They will be added in future software updates. All triggers on this page are supported from MASSO software v5.13, API version 1.0.0.

System triggers

Use these to set up variables, run background checks and respond to the controller's state.

System triggers in the Custom Scripts window

TriggerRunsCommon uses
On Power UpOnce, when MASSO powers onSet variables, initialise states
BackgroundContinuously, at regular intervalsMonitor states, update variables
WARNING
Keep the Background trigger short. Avoid complex loops, file operations and long calculations, as they slow down the controller.

Recovery with Safe Mode

If a script stops MASSO from starting, Safe Mode starts the controller without loading any Lua scripts so you can log in as Admin and disable or fix the script.

Safe Mode warning

1
Connect a USB keyboard to MASSO. On MASSO G3 Touch you can use the external USB port.
2
Restart the controller. As soon as the screen appears, press F8 repeatedly until the Safe Mode warning shows. If it doesn't appear within 5 seconds, restart and try again.
3
Log in as Admin (user login is disabled in Safe Mode), disable or fix the script, then restart MASSO normally.

Homing triggers

Homing triggers

TriggerRuns
Before HomingBefore homing starts
After HomingAfter homing completes successfully
Homing ErrorWhen homing fails or a limit error occurs

E-Stop and door triggers

E-Stop triggersDoor triggers
TriggerRuns
E-Stop PressedImmediately after the E-Stop is pressed
E-Stop ReleasedImmediately after the E-Stop is released
Door OpenedImmediately after the door sensor opens
Door ClosedImmediately after the door sensor closes

Tool change triggers

Tool change triggers

TriggerRuns
Before Tool Change (M6)Before the tool change starts. Can return a control value to change how the tool change proceeds.
After Tool Change (M6)After the tool change completes
Tool Change ErrorWhen a tool change error occurs

Interface triggers

Action Button 1–16 runs when that action button is pressed on screen. Set up the button window with the M.gui functions.

Action button triggersAction button window on the MASSO screen

Job triggers

End of Job runs when a job finishes or is stopped.

Job triggers