Custom Scripts (LUA)
Overview
LUA is a fast lightweight, powerful scripting language that will allow users to to write their own custom scripts and Macros.
Scripts can be triggered by multiple events on your MASSO controller such as turning on or off the spindle, triggering of various alarms, or calling a custom Mcode from your Gcode file.
There is provision to allow the user to add a custom script before and after a tool change to allow more flexibility in existing tool changers For example the spindle may need to be orientated to a particular position in case of a 5 axis spindle before a tool change and reorientate back to the original position after the tool change. If a completely different tool change logic is required then the user can write their own tool change logic to suit their machine and requirements.
Some great examples of use cases:
Smart Automation & Workflow Logic
- Automatic Warm-Up Routine - Run a spindle warm-up sequence automatically every morning when the controller powers up.
- Auto Shutdown or Sleep After Job - When a job completes, Lua checks for spindle temperature, turns off mist/flood, and safely powers down after a delay.
- Dynamic Job Timer and Notification - Use M.sys.get_job_runtime() to show elapsed job time on-screen or send message to your myWorkshop smartphone devices.
- Auto Tool Offset Verification - After each tool change, use Lua to probe the tool length and compare against the stored offset. Warn if deviation > tolerance.

Custom UI / Machine Behavior
- Custom Button Actions - Assign on-screen buttons to run Lua scripts that trigger multiple machine actions (e.g., “Clamp Material” runs 3 outputs in sequence).
- Dynamic Screen Messages - Display live process info — material type, part count, or next maintenance time — on a custom display line.

Smart IO & Integration
- External Device Integration - Use Lua to send/receive data over serial or TCP/IP to devices like barcode scanners, scales, or PLCs.
- Smart Mist/Flood Logic - Automatically turn on mist when machining aluminum and flood for steel, based on material Lua variable in G-code.
- Conveyor or Robot Integration - After machining, trigger a conveyor or robot to move the part, and wait for “done” signal before continuing.
- Automatic Barcode Label Printing - After each part, send ZPL/PCL commands to a printer using M.printer.write() to generate custom QR labels with job data.
Production & Process Tracking
- Automatic Serial Number Generator - Lua increments and prints serial numbers for each part made, embedding them into G-code or labels.
- Predictive Maintenance Tracker - Log spindle hours and issue alerts when it’s time to service or replace consumables.
- Tool Life Management - Automatically switch to backup tool after a set number of uses or machining time per tool.
- Cloud Reporting - Push job completion data to a web API (for example, to MASSO Link or myWorkshop) at the end of each cycle.

Machine & Motion Customization
- Custom Homing Sequences - Implement unique homing logic for machines with secondary encoders or multiple sensors.
- Dynamic Feedrate Adjustment - Adjust feedrate or spindle speed mid-job based on cutting load feedback or input signals.
- Adaptive Machining - If a probe detects material thickness variation, dynamically update Z offsets before machining.
- Safe Mode / Maintenance Mode - Start in “maintenance mode” if a specific input (like a key or button) is held during power-up.
- Jog Automation - Automatically move axes to specific maintenance positions with safety checks.

Labeling, Printing & Communication
- QR Label Printing with ZPL - Generate a part label including QR code for serial, job name, and operator name.
- Custom Reports in PCL - Send formatted PCL commands to a standard laser printer for shift-end summary or maintenance reports.
- Part Tracking via Barcode Scan - Lua reads serial via serial input and updates log files or selects correct G-code automatically.

IoT & Cloud Connectivity
- Machine Heartbeat Signal - Periodically send job status to an IoT server or MQTT broker using RS485 or Wi-Fi module.
- Remote Alerts - Message alerts when the job ends, tool breaks, or an error occurs.
- Live Production Dashboard - Use Lua to periodically log cycle times to a shared folder for live dashboards or OEE tracking.

Advanced / Specialized Use Cases
- Automatic Pallet Changer Control - Lua coordinates pallet rotation, clamping, and verification before machining resumes.
- Laser Marker or Engraver Integration - Automatically send ZPL commands to engrave serial/QR codes with laser marking systems.
- Temperature-Controlled Machining - Monitor spindle or coolant temperature and adjust feeds/speeds accordingly.
- Custom Probe Cycles - Define your own probing macros using Lua with logic branching and conditional messages.
- AI-Assisted Adaptive Logic - Lua uses sensor inputs (e.g., vibration or current sensors) to adjust feed or stop machining if anomalies are detected.
Marketing / Demo Ideas
- “Smart CNC Shop” Demo - A single MASSO running multiple Lua scripts — automatic warm-up, serial tracking, label printing, and cloud upload.
- “Machine Talks to the Cloud” Demo - Show Lua pushing production stats to a dashboard every 5 minutes.
- “Zero-Downtime Tool Change” Demo - Lua detects worn tool, auto-loads backup, and continues the job without user intervention.

Scripts can be password protected for those who wish to create and sell their own scripts and scripts can be limited for use on a series or a single MASSO serial number. Protected scripts have a visible section editable by the user for things such as variables which are custom to each machine while the rest of the script remains hidden.
Lua License Acknowledgment
This product includes the Lua programming language,
developed by PUC-Rio (Pontifical Catholic University of Rio de Janeiro).
Lua is free software distributed under the terms of the MIT License:
Copyright © 1994–2024 PUC-Rio
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
More information about Lua is available at www.lua.org.
Spanish
French
German
Simplified Chinese