Custom Scripts (Lua)

Lua is a fast, lightweight scripting language for writing your own scripts and macros on MASSO. Scripts can be triggered by controller events – such as the spindle turning on or off, alarms, or a custom M-code in your G-code.

1. Custom tool change logic

You can add a script before and after a tool change to extend an existing tool changer – for example, orienting a 5-axis spindle to a set position before the change and back afterwards. If you need completely different tool change logic, you can write your own to suit your machine.

2. Example uses

INFORMATION
These are ideas for what Lua can be used for. Lua support is being extended release by release, so check the function reference pages for what your software version supports.
Job automation
  • Warm-up routine – run a spindle warm-up at power-up.
  • Shutdown after job – check spindle temperature, turn off mist/flood and power down after a delay.
  • Job timer – use M.sys.get_job_runtime() to show elapsed time or message myWorkshop devices.
  • Tool offset check – probe tool length after a change and warn if it's out of tolerance.
Custom UI and behaviour
  • Custom buttons – run a script from an on-screen button, e.g. “Clamp Material” switching several outputs in sequence.
  • Live messages – show material type, part count or next maintenance time.
Smart I/O and integration
  • External devices – barcode scanners, scales or PLCs over serial or TCP/IP.
  • Mist/flood selection – choose mist or flood from a Lua variable set in G-code.
  • Conveyor or robot – trigger part removal and wait for “done”.
  • Label printing – send ZPL/PCL with M.printer.write().
Production tracking
  • Serial numbers – increment and print one per part.
  • Maintenance – log spindle hours and flag when service is due.
  • Tool life – switch to a backup tool after set uses or time.
  • Cloud reporting – send job data to MASSO Link or myWorkshop at cycle end.
Machine and motion
  • Custom homing for specialised machines.
  • Dynamic feed/speed based on load or inputs.
  • Adaptive machining – adjust Z offsets from probed material variation.
  • Maintenance mode – start in a safe mode if an input is active at power-up.
  • Jog automation – move to preset maintenance positions with safety checks.
Connectivity and advanced
  • Heartbeat and alerts – job status to an IoT server or MQTT broker; notify on job end, tool break or error.
  • Production dashboards – log cycle times for OEE.
  • Pallet changers, laser markers, temperature-controlled machining, custom probe cycles and sensor-based adaptive logic.

3. Script protection

If you create and sell your own scripts, you can:

  • Password-protect them.
  • Limit them to specific MASSO serial numbers.
  • Lock the core logic while leaving chosen variables editable, so machine-specific settings can still be changed.

Lua script screen

See Lua Editor for password and serial number locking.

4. Lua licence acknowledgment

This product includes the Lua programming language, developed by PUC-Rio (Pontifical Catholic University of Rio de Janeiro). Lua is distributed under the MIT Licence.

Copyright © 1994–2024 PUC-Rio

Permission is granted, free of charge, to use, copy, modify, merge, publish, distribute, sublicense and/or sell copies of the software, subject to the conditions of the MIT Licence. The software is provided “as is”, without warranty of any kind.

For more information, visit www.lua.org.