Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: learman on July 09, 2015, 09:47:45 AM
-
Hello
I am working on converting one of my workstations from Mach3 to Mach4. Having trouble understanding the Lua scripting. Could someone take a look at this simple Macro and help convert it to Lua.
Thanks
Josh
-
Try this:
function m1002()
local mInst = 0;
local inst = mc.mcGetInstance(mInst);
local NumValue = 0;
local hSig = 0;
local rc = 0;
local StringValue = "";
local state = 0;
--There is no rc error checking in this....
hSig, rc = mc.mcSignalGetHandle(inst,mc.ISIG_INPUT2);
state, rc = mc.mcSignalGetState(hSig);
if (state == 0) then --0 is Input2 NOT active, 1 is Active
--send error message to Machs error message box
mc.mcCntlSetLastError(inst, "CHECK ENERGY MONITOR!!");
--Optional send error message to a wx Message box
--wx.wxMessageBox("CHECK ENERGY MONITOR!!");
end
local StopDebugVar = 0;
end
if (mc.mcInEditor() == 1) then
m1002();
end
--have fun!
--Scott
-
I don't think i'm saving it properly. I have it saved in the profile i'm using under macros.
I also tried running one of the codes in the Luaexamples file with no luck.
Thanks for the help Scott!