Machsupport Forum
MachPro => MachPro General Discussion => Topic started by: tbadger on March 07, 2026, 04:45:09 PM
-
I'm wanting to add a PLC script that calls a module for Mach status lighting. In Mach 4, that seemed pretty straight forward. I'm not a seasoned coder, so there is little that is intuitive about LUA coding for me. In Mach Pro, the "new" PLC Script just has the following:
if m.CommonPLCScript ~= nil then
m.CommonPLCScript()
end
I want to insert this code into the PLC Script, so that it calls the towerscript.lua module.
if towerscript == nil then
towerscript = require "towerscript" -- Load's towerscript.lua from a path. probably C:\Mach4\Modules
end
towerscript.PLCScript()
I tried just pasting it at the end of the previous lines, but that did not seem to work. I've found little information in the documentation that would guide me in the right direction.
-
Okay, might just be user error. I did not restart Mach Pro after updating the script. On restarting, it does seem to be working as expected.
-
In MachPro there's actually already a built in method for handling Light Stacks inside of Configure → Control → Settings. Alternatively you can also handle it through the GMS plugin as well.
If you prefer the lua code route, under the Service → Maintenance tabs, we have a Compile Scripts button that should apply your custom programming and most changes, so you no longer have to power cycle Mach.
In an ideal sense, we prefer to not have custom programming on the newer software as it becomes a nightmare to support. We are working on documentation on how to handle all these things.
-
Thanks Paul - looking forward to the documentation. As I'm not a coder, but can figure out mostly how to add custom stuff that others have built and get it to work. Since Mach Pro has changed so much, its a challenge sometimes to figure out where to get things done. While exploring further, I did note the Compile Scripts button on the Service tab. I think it is mostly getting used to the changes and knowing how things are done in Pro.
I think some clear examples of what might be considered typical of what someone might want to do would be helpful. In other words, beginning to end.
BTW, I am on the Beta, so happy to review the doc in progress.
-
Edit Screen -> PLC script edit.
Add that snippet to the PLC script. Exit editor and then exit from Edit screen. It will ask if you want to save.
Say yes and your done. there should not be any reason to restart Mach at that point.
As for the config->control->settings light stack, it is NOT similar to what you are putting in place. It is meant for a tower Light that has 3 positions. And you have no control really on those.
the PLC.Towerscript() has alot more to say about machine status and is programmable to change what you'd like to see. I'm the one who wrote the towerscript and looked at various methods to implement
what I wanted, which did include the settings light stack.
Colten
-
In an ideal sense, we prefer to not have custom programming on the newer software as it becomes a nightmare to support. We are working on documentation on how to handle all these things.
thank you for verifying what I'm suspected from the start of the beta program. Mach it seems is locking down features from consumer use. When Mach removes the Edit->screen function, I'll be saying goodbye and thanks for all the fish. I understand the support view point. but locking it down so the consumer ie me and many others is rather short sighted. Fixing bugs in the program that have been IN mach for years now would definitely be worthwhile. But then I'll assume it will never be backported to Mach4. That sucks. We all paid good money for a program which was supposed to be and usually is a massive upgrade from Mach3.