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.
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.
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.
Trigger
Runs
Common uses
On Power Up
Once, when MASSO powers on
Set variables, initialise states
Background
Continuously, at regular intervals
Monitor 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.
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
Trigger
Runs
Before Homing
Before homing starts
After Homing
After homing completes successfully
Homing Error
When homing fails or a limit error occurs
E-Stop and door triggers
Trigger
Runs
E-Stop Pressed
Immediately after the E-Stop is pressed
E-Stop Released
Immediately after the E-Stop is released
Door Opened
Immediately after the door sensor opens
Door Closed
Immediately after the door sensor closes
Tool change triggers
Trigger
Runs
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 Error
When 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.
Job triggers
End of Job runs when a job finishes or is stopped.